Free ways to optimize OpenCart speed

Website loading speed affects conversion rates and search rankings. If
you think optimizing website loading speed on your own is too complex or
impossible, then this article is for you. Let's examine OpenCart
optimization methods that don't require purchasing additional modules or
paying for services.
Main Stages of OpenCart Loading Speed Optimization
Twig CacheOpenCart has built-in template caching. It must be enabled in the admin panel. This reduces the number of calculations when generating pages. So, open the main admin Dashboard page, click the gear icon button to access additional settings, and enable Theme cache.
Static File CachingCSS, JS, and images should be cached at the server level. For this, it's sufficient to set up rules in Apache or Nginx configuration with long expires or cache-control headers. Usually, static file caching can be enabled in the hosting control panel. If you don't have this option, add caching rules to the .htaccess file (in the site root):
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
Replacing External Resources with Internal Ones Download all external scripts, styles, and fonts from CDNs to your server. This will reduce the number of DNS requests and speed up loading. Pay special attention to Google Fonts, jQuery, Bootstrap, and Font Awesome from CDNs. Try to make your site load only its own resources, without depending on external servers. Store scripts and fonts on your server and connect them locally.
Iframe DeferringIf you use iframes (YouTube videos, Google Maps), add the loading="lazy" attribute or implement deferred loading via JavaScript with a 2-3 second delay after the main content loads.
Deferred Script Loading
Add the defer attribute to <script>
tags or move
non-critical scripts to the end of <body>
. Keep critical
JavaScript in <head>
.
Add the loading="lazy" attribute to <img>
tags. For main
images (logo, banners above the fold), use loading="eager" or
fetchpriority="high".
If the server supports HTTP/2, enable it (in the hosting panel). This speeds up loading multiple files simultaneously. Also enable compression in the server configuration. GZIP is supported everywhere, while Brotli is even more efficient if available. If you don't have these options, add GZIP compression rules to .htaccess:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
WebP Image Format WebP format reduces image weight several times over. There's a free module for OpenCart that automatically converts images to WebP. This reduces file sizes by 25-35% without quality loss. The module can be obtained here.
Database OptimizationUse the free OpenCart Turbo script for automatic database table optimization. It adds missing indexes and changes the DB engine to InnoDB, which is better suited for OpenCart. The script runs with one click and requires no additional knowledge or configuration.
If you understand programming, review OpenCart models and remove unnecessary JOINs in SQL queries. Most often, you can optimize queries in product and category models. For example, if you don't use discount systems, promotions, reviews, or ratings, you can remove data retrieval from these tables.
In store settings, disable:
- Product count in categories (System → Settings → Options → Product Count)
- Online visitor tracking (System → Settings → Options → Customers Online)
These features create additional database queries with each page load.
Replacing Font Awesome IconsReplace Font Awesome icon font with SVG sprite or PNG sprite. This reduces CSS size and the number of HTTP requests. Create one file with all needed icons.
CSS and JS CleanupRemove unused styles from Bootstrap and other CSS files. Combine multiple CSS/JS files into one. Minify code using online tools.
Script RelocationMove all non-critical JavaScript files to the footer, keeping only critical code for content display in the header, such as just the jQuery library.
Session CachingIf you have access to Redis or Memcached, configure them for session caching and SQL query result caching. This significantly speeds up database operations.
Result Verification
To evaluate the effect, check speed using:
- PageSpeed Insights - Google analysis with recommendations
- GTmetrix - detailed report with request waterfall
- WebPageTest - testing from different locations and devices
Test the homepage, product category page, and product card. These pages are most frequently visited by users. Changes should be tested gradually. Take measurements before and after each stage.