Conversion Optimization

How to Speed Up Magento 2 Site - 19 Proven Ideas

If you are struggling to get conversions, here are some Magento 2 speed optimization tips to try, starting today! 

How to Speed Up Magento 2 Site - 19 Proven Ideas

With recent Google updates, website speed has become a prominent ranking factor. 

40% of shoppers will leave a site if takes more than three seconds to load. 

If you are facing a low page speed score on your Magento 2 store, here are some optimization tips to implement.  

In this blog, we’ll cover: 

Why does Magento site speed matter?

How to test Magento 2 site performance?

Why your Magento 2 site is slow?

19 Magento 2 speed optimization tips

Why does Magento site speed matter?

Here are some reasons why Magento speed matters:

✔️ Improves customer experience. A slow website is frustrating for customers and can lead to them abandoning their carts or not visiting your site again.

✔️ Increases conversion rates. Studies have shown that even a one-second delay in page load time can lead to a decrease in conversions.

✔️ Boosts SEO rankings. Google and other search engines take page load speed into account when ranking websites. A faster website will rank higher in search results, which can lead to more traffic.

✔️ Reduces costs. A slow website can lead to increased costs in terms of lost sales, customer support, and server maintenance.

How to test Magento 2 site performance?

There are a few ways to test Magento 2 performance and identify any performance issues:

✔️ Use a tool like Google PageSpeed Insights or GTmetrix to test the loading speed of your website.

✔️ Use a tool like JMeter to simulate a load test on your website.

✔️ Monitor your server logs to see how much traffic your website is receiving and how it is performing.

✔️ Conduct user testing to see how easy it is for users to navigate your website and complete tasks.

Why is your Magento 2 site slow?

Here are some common reasons why Magento 2 can be slow:

✔️ Too many extensions: Magento 2 is a very powerful platform, and it can be tempting to install a lot of extensions to add new features and functionality. However, too many extensions can slow down your Magento 2 store.

✔️ Poorly coded extensions: Not all extensions are created equal. Some extensions are poorly coded and can cause performance issues.

✔️ Outdated software: Magento 2 is a constantly evolving platform, and it's important to keep your software up to date. Outdated software can have security vulnerabilities and can also slow down your Magento 2 store.

✔️ Unoptimized database: The Magento 2 database can become bloated over time, which can slow down your Magento 2 store. It's important to regularly optimize your database to keep it running smoothly.

✔️ High traffic: If your Magento 2 store gets a lot of traffic, it can slow down. There are a few things you can do to mitigate this, such as using a caching plugin and optimizing your images.

✔️ Server issues: If your server is not up to the task of running Magento 2, it can slow down your store. Make sure your server has enough RAM, CPU, and storage space to handle your Magento 2 store's traffic.

19 Magento 2 Speed Optimization Tips 

If you are struggling to get conversions, here are 19 Magento 2 speed optimization tips to try, starting today! 

1. Regularly update to the latest Magento 2 version

Magento 2 releases new versions of the CMS almost every three months. 

Each release solves multiple bugs and security fixes. 

Additionally, Magento 2 also ceases to support older versions by certain dates. 

Therefore, sticking to an older version is futile and only slows down your website. 

When this blog is published (October 2023), the latest and most optimized version is 2.4.6-p2.

You can keep track of Magento versions here

Note the dates of support end times so you can plan your migration and update the Magento 2 store accordingly. 

2. Choose a reliable hosting setup

If you have cheap shared web hosting, it can slow down your Magento 2 website. 

The main problem is when you have a minimum number of visitors. 

However, the hosting setup cannot handle increasing website visitors as your Magento 2 store grows. 

Server requests get piled in a queue, so each visitor has to wait for the previous requests to be executed.

If your website has slowed down, check if your hosting meets Magento's minimum system requirements as listed here

Before choosing the right hosting server for Magento 2 speed optimization, ask the following questions:

✅ How many website visitors do you have on the site simultaneously and on the load it has? 

✅ How many resources does one visitor need? 

✅ How much time does the server spend on one visitor?

3. Use lightweight Magento themes

As part of your Magento 2 speed optimization strategy, focus on website themes.

Complicated Magento 2 themes can significantly slow down your website. 

For instance:

You’ve applied a theme with lots of widgets and custom blocks. 

This makes the Magento 2 speed slow as it needs to load all features. It’s a nightmare for visitors with slow internet. 

As a result, visitors will bounce off and experience bad customer experiences.

Before purchasing a theme, ensure it runs fast on the demo and test it with GooglePageSpeed for a more detailed analysis.

4. Clean database logs

While Magento 2 has improved its features in various ways, its database still needs improvement. 

Magento 2 automatically and frequently generates new log files, so removing the old ones should not cause any problems. 

The database performance improves significantly when removed because of the decreased lag in process execution.

Remember: Take a backup before making new changes to the database.

To set the log time, follow these steps:

Step 1: Navigate to the Stores → Configuration.

Step 2: Expand the Advanced → System and open the MySQL Message Queue Cleanup section.

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

Step 3: Set the specific amount of time in New Messages Lifetime to automatically clean the old log files.

Step 4: Once complete, click Save Config.

5. Use Redis to avoid built-in cache

There are some prerequisites to set up Magento 2 Redis Cache on the hosting server:

  • Redis Server
  • PHP Redis Extension

Here’s how to configure Redis default caching for Magento 2 speed optimization:

Run the setup: config: set command and specify parameters that are specific to Redis default caching.

With the following parameters:

--cache-backend=redis enables the Redis default caching. If this feature has already been enabled, omit this parameter.

--cache-backend-redis-<parameter>=<value> is a list of key-and-value pairs that configure the default caching:

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

Here’s how to configure Redis page caching:

To configure Redis page caching on Commerce, run the setup:config:set command with additional parameters.

With the following parameters:

--page-cache=redis enables Redis page caching. If this feature has already been enabled, omit this parameter.

--page-cache-redis-<parameter>=<value> is a list of key-and-value pairs that configure page caching:

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

6. Manually update the indexers

Since Magento allows bulk data, it can decrease load time.

That’s why, it’s important to reindex Magento's indexers.

The reason is that the indexers usually get updated by the core system on every default stored object. 

However, the system does have some flaws that can slow down Magento 2 site. Therefore, it’s best to carry out the indexer update by hand.

On Magento 2, run the CLI command below in the root directory with the help of the SSH terminal:

php bin/magento indexer:reindex

For instance, you can develop an indexer for product labels. 

Magento 2 stores often use label tags to reflect a product's advantages (its properties, if it's in stock or on a discount, etc.). 

One page can have several sliders with 20 or 50 products. In this case, labels are recalculated for each product.

Since these labels are updated once a day or based on certain actions, you can make an indexer that'll save the calculated labels for each product. 

Recalculation could occur once a day, or if it deals with warehouse updates, you can call the reindex of one record when the number of items in the warehouse changes.

7. Disable Flat Catalog Category

Magento 2 no longer recommends flat catalogs due to indexing and performance issues.

Before disabling the feature, it is important to check all extensions that are required to work with the flat catalogs. 

To speed up Magento 2 website, disable Flat Catalogs:

  • Navigate to Stores → Configuration → Catalog.
  • Expand the Storefront section.
  • Set No in the Use Flat Category and the Use Flat Catalog Product fields.
How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

8. Apply lazy loading on images

Image sizes significantly impact a Magento 2 store's speed. 

Media files can take quite a long time to load

Lazy loading lets you load images, GIFs, and other heavy media as a visitor scrolls down the page. 

This means that the browser will not try to load the whole page at once. 

Lazy loading shows a lower-resolution image or a placeholder image. Then, it will switch on the fly to the high-quality source image.

As part of Magento 2 speed optimization, lazy loading means:

  • Better perceived loading speed (important for user experience).
  • SEO-friendly implementation (search engines will crawl images as usual).
  • Bandwidth savings (since most visitors will not scroll to the bottom of the page).

Pro Tip 🚀

After reviewing many Magento 2 store audits, and even Google recommends saving images in JPEG 2000, JREG XR, and WEBP formats instead of old PNG and JPG. 

9. Use HTML <picture> Tag

To speed up Magento 2 store for mobile shoppers, consider using the HTML <picture> tag.

It’s very useful for responsive designs and pages with lots of images

With this tag, you can define multiple image sources within a single <picture>. 

The correct image selection will depend on the viewport and the min-width parameter of the image.

This is beneficial when you want to offer the browser the ability to choose the best-fitting image for a certain dimension. 

The most common example would be a desktop vs. mobile browsing experience where the viewport value will fluctuate quite a bit. 

It can be time-intensive to implement <picture> tags from the ground up for the Magento 2 site.  

Here's a sample code on how to teach other add-ons on your Magento 2 store how to work properly with the <picture> tag:

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

10. Minify CSS and JavaScript 

The time it takes to load CSS and JavaScript (JS) files can be reduced by merging, minifying, and bundling separate files into a single file.

a. Merge or minify CSS files

To enable CSS merging or minification, go into Admin > Stores > Setting > Configuration > Advanced > Developer > CSS Settings.

→ To enable CSS merging, run this command locally:

bin/magento config:set --lock-config dev/css/merge_css_files 1

Commit changes to the app/etc/config.php file and redeploy.

→ To enable CSS minification, run this command locally:

bin/magento config:set --lock-config dev/css/minify_files 1

Commit changes to the app/etc/config.php file and redeploy.

b. Minify JS files

On the Admin sidebar, go to Stores > Settings > Configuration > Advanced > Developer > JavaScript Settings.

→ To enable JS minification, run this command locally:

bin/magento config:set --lock-config dev/js/minify_files 1

Commit changes to the app/etc/config.php file and redeploy.

c. Merge and bundle JS files

You can turn on merging or bundling in the Commerce Admin (merging and bundling cannot be enabled at the same time): 

Stores > Settings > Configuration > Advanced > Developer > JavaScript Settings.

Enable the built-in bundling (basic bundling) from the command line:

php -f bin/magento config:set dev/js/enable_js_bundling 1

11. Use Elasticsearch for instant results

43% of online shoppers use the search function right from the start. 

Magento 2 Elasticsearch is a server-based tool capable of a very high speed of full-text search. 

With an implemented cache, Elasticsearch can retrieve the results in a few seconds and also improve response times, especially when you have a large category.

To integrate Elasticsearch and speed up Magento 2 store, the following steps are needed:

  • install proper version of Elasticsearch on the server
  • install proper version of the PHP Elasticsearch library as a project dependency
  • specify the installed Elasticsearch version in Magento configuration (Catalog > Catalog Search > Search Engine

12. Enable GZIP compression

GZIP compression is a standard method of compressing larger files on your website. 

It’ll enable your Magento 2 store to load much faster providing for a smoother and faster experience. 

Follow the steps below to successfully enable Gzip compression and speed up Magento 2 store:

  • Assure the mod_deflate is on in apache. You can do that by creating an info.php file and calling phpinfo(); You will get the specs of PHP/APACHE on the browser. Remove it when you have completed the process.
  • Navigate to your htaccess file and add the code given below:
How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

13. Integrate Content Delivery Network

Magento 2 stores have a lot of media files and store functions.

A CDN solution reduces the distance between the stored content & the end user. 

However, a CDN solution is not built-in for Magento 2.

Here’s how to configure a content delivery network and speed up Magento 2 store:

  • On the Admin sidebar, go to Stores > Settings > Configuration.
  • In the left panel under General, choose Web.
  • In the upper-left corner, set Store View as needed.
  • Expand the Base URLs section and do the following:
How to Speed Up Magento 2 Site - Magento 2 Speed Optimization
  • Update the Base URL for Static View Files with the URL of the location on the CDN where static view files are stored.
  • Update the Base URL for User Media Files with the URL of the JavaScript files on the CDN.
    Both these fields can be left blank, or can start with the placeholder: {% raw %}{{unsecure_base_url}}{% endraw %}
  • Expand the Base URLs (Secure) section and do the following:
How to Speed Up Magento 2 Site - Magento 2 Speed Optimization
  • Update the Secure Base URL for Static View Files with the URL of the location on the CDN where static view files are stored.
  • Update the Secure Base URL for User Media Files with the URL of the JavaScript files on the CDN.
    Both these fields can be left blank, or can start with the placeholder: {% raw %}{{unsecure_base_url}}{% endraw %}
  • When complete, click Save Config.

14. Delete unnecessary fonts

A Magento 2 store we recently worked with enabled many trending designs, themes, and fonts. 

What most Magento 2 store owners don’t realize is that fonts can reduce page loading speed even if they are not used.

Sometimes, when you add some custom font to the <head> section of the page configuration file. 

Even if the font is used or not, it will be loaded anyway.

So, to speed up Magento 2, delete unused fonts. 

15. Switch to production mode

All live Magento 2 sites must have Production mode since full caching of web pages is used in Production mode, which ensures smooth and efficient work for clients on the site.

In Magento 2, add a command that switches Magento modes from developers to production mode. 

Moreover, production mode brings in better performance because static view files are populated in the pub/static directory and because of code compilation.

Step 1: SSH into your site’s server.

Step 2: Navigate to the site’s root- then to the /bin directory.

Step 3: Run the following command: php bin/magento deploy:mode:set {mode} [-s/-skip-compilation] 

where:

{mode} is a required parameter (Developer or Production);

[-s/-skip-compilation] is an optional parameter(it’s used for skipping the compilation when switching to the code>Developer mode).

Pro Tip 🚀

When switching to the Production mode, we recommend clearing the contents of the following folders (be careful not to delete the .htaccess files, they register configuration changes for each directory):

  • var/cache
  • var/di
  • pub/static
  • var/generation
  • var/view_preprocessed

16. Enable full-page cache 

Applying a full-page cache for Magento provides relevant content to website visitors as fast as possible.

Here’s how to configure the Full Page Cache and speed up Magento 2 store:

Step 1: On the Admin panel, click Stores. In the Settings section, select Configuration.

Step 2: Select System under Advanced in the panel on the left

Step 3: Open the Full Page Cache section

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

Step 4: In the Caching Application field, select one of the following

  • Built-in Application
  • Varnish Caching

Step 5: In the TTL for the public content field, set the time-out for the page cache. The default value is 86400.

17. Implement Varnish cache

Magento 2 Varnish is a cache to help accelerate web applications, technically known as HTTP accelerator. 

It’s designed to accelerate content-heavy dynamic pages to improve the overall performance of the Magento 2 stores. 

Here’s how to configure Varnish cache on your Magento 2 site:

If you choose the Varnish option in the Caching Application field, complete the Varnish Configuration section as the following instructions:

How to Speed Up Magento 2 Site - Magento 2 Speed Optimization

Step 1: In the Access list field, enter the IP addresses, and IPs access list separated with ',' that can purge Varnish configuration for config file generation. If the field is empty default value localhost will be saved.

Step 2: In the Backend host field, enter the IP address of the backend host that generates config files. The default value is localhost

Step 3: In the Backend port field, identify the backend port that is used to generate config files. The default value is: 8080

Step 4: In the Export Configuration field, click the button for the version of Varnish that you use.

  • Export VCL for Varnish 3
  • Export VCL for Varnish 3

Step 5: When complete, click Save Config

18. Fix 3rd party plugin issues

If your Magento 2 store has to handle large data volumes or if your pages are jammed with too many elements, like widgets or sliders.

This significantly slows down Magento 2 store performance. 

Moreover, using multiple add-ons from different vendors can significantly degrade Magento 2 site performance. 

This happens because each extension usually works independently, re-requesting the data it needs (for example, on a product), even if another extension has already requested it.

To fix this issue, analyze which plugins are working and not working for your Magento 2 store.

When you're through with that, either optimize the extensions or remove them. 

19. Use PWA for a faster experience 

PWA websites are fast, secure, responsive, and cross-browser compatible. They can work offline and act like a native app on mobile.

On Magento 2 PWA, the browser sends a request to a server through APIs, which returns HTML with a link to JS files. 

The browser builds page templates without dynamic content. 

These templates are cached and don’t need loading when the user opens other pages. 

The backend sends only the required data, which creates less server load, and accelerated speed.

There are 3 ways to build PWA as part of Magento 2 speed optimization:

  • utilize modern frameworks like React.js, Vue.js, or Angular.js,
  • premade themes, and
  • install add-ons and extensions.

Recommended reading: 

Magento checkout customizations: 12 intelligent strategies for more conversions

Boost Magento product page sales: 35 fresh ideas

Before you go...

98% of visitors who visit an online site—drop off without buying anything.

Why: user experience issues that cause friction for visitors.

And this is the problem ConvertCart solves.

We've helped many Magento 2 stores improve user experience—and 2X their conversions.

How can we help you:

Our conversion experts can audit your site—identify UX and Magento 2 site speed issues, and suggest changes to improve conversions.

Conversion rate optimization
Thank you.
We'll be in your inbox soon 🙂
Oops! Something went wrong while submitting the form.
X
Conversion rate optimization
x