A Complete Guide to Magento 2 Speed Optimization

As a leading Magento extensions company, we believe that for an online store, speed has a direct impact on its success. After all, slow speeds lead to poor user experience, decline in search engine rankings, and more. Ultimately, this leads to decreased store sales, thereby undermining your store’s financial viability. This guide will walk you through everything there is to know about Magento 2 speed optimisation.

What is Magento 2 Speed Optimisation?

It refers to the process of improving overall performance and loading times of your Magento 2 store. This involves adopting a multifaceted strategy that focuses on various aspects of the store, including the server side, product images, and the customised code.

Importance of Magento Performance Optimization?

Improving your Magento 2 store’s performance is important due to several reasons:

1. User Experience

According to research , the acceptable loading time for a website is 3 seconds. Given how internet speeds have improved worldwide, we expect this figure to be around 2 seconds now. Therefore, faster load times improve the user experience and reduces the bounce rate. This has a positive impact on the conversion rate.

2. Search Engine Optimisation (SEO)

SEO is a key marketing strategy for any online store. Google and other search engines have repeatedly mentioned that loading times are a critical ranking factor. Thus, faster loading times improve your online rankings. The increase in organic traffic can improve your Magento 2 store’s sales .

3. Reduction in Resource Consumption

Lack of optimisation leads to increase in server-related resource consumption. This not only increases operating expenses, but also puts undue pressure on the server. This can result in website loading errors, slow loading times, and more. Optimisation ensures efficient utilisation of resources.

4. Increase in Revenue

As mentioned repeatedly, an optimised site has a direct impact on the store’s revenue. Faster load and checkout times reduce cart abandonment rates. Unfortunately, cart abandonment is a menace for every store owner. The global cart abandonment rate is more than 70 per cent, which shows its severity.

5. Future Proofing

Internet speeds will only improve further in the coming years. By optimising your Magento 2 store, you are future proofing your site. By staying ahead of the competition, you’ll have a competitive edge. This can easily translate into increased sales and enhanced brand loyalty.

Magento 2 Speed Optimization Prerequisites

Before we discuss the numerous ways to optimise your Magento 2 store, you need to visit Google PageSpeed Insights. Follow the below steps:

Step 1: Enter your store’s URL.

magento-2-speed-optimization

Step 2: Click on Analyse

Google will analyse your entire website’s performance for Mobile and Desktop Devices.

magento-2-speed-optimization

Step 3: Save the report or take screenshots of key metrics.

After optimising your store, re-run the test to assess if there’s any improvement.

The figures below our store’s performance across Mobile and Desktop devices.

magento-2-speed-optimization

There’s room for improvement as far as mobile devices are concerned. However, keep in mind that achieving a perfect score is neither desirable nor possible in all cases. Nevertheless, one should always focus on continuous improvement and finding innovative ways to enhance the user experience.

magento-2-speed-optimization

As far as the store’s desktop performance is concerned, fmeextensions.com performs extraordinarily well. This due to the efforts and creativity of our Magento 2 development experts. If you need to hire a Magento 2 developer or team for your store or client, contact us right away.

How to Speed up Magento 2?

Now, let us turn our attention towards Magento 2 speed optimisation. Various factors contribute to your Magento 2 store being slow. There are, nonetheless, different ways to counter each factor. In this article, we are going to propose all the possible Magento 2 performance optimisation tips.

Some of these tips will have significant results while others will be less noticeable. However, it does not mean they carry no importance at all. Instead, for the best possible performance, we need to focus on all the aspects. Without further ado, let’s start the discussion now.

11 Proven Magento 2 Speed Optimisation Tips

1. Choose the Right Hosting

Recently, a client approached us to improve their website’s loading times. When we asked about the hosting details, they mentioned that they had a very reliable hosting provider, and the issue was not with the hosting service. They were adamant that we looked into the website’s code.

After our insistence, we managed to obtain the hosting details. Upon closer inspection by our Magento development experts, we found that the hosting provider was not ideal for Magento 2 stores. Secondly, while their store was based in the US, the server location was Europe.

After convincing them to change their hosting service, the loading times improved significantly. They did not have to tweak the website’s code, invest in third party extensions, or anything like it. All they needed to do was buy a reliable hosting service. Keep in mind that a hosting plan is a foundation of a fast website.

Therefore, we recommend always going for a premium hosting plan. This investment will pay off in the form of quick server response. Magento stores can be really large in terms of size and cheap hosting plans just do not help. On top of it, not all hosting servers are ideal for Magento 2 stores.

How do you know you need to change or upgrade your hosting plan?

Here is a simple tip to help you decide. Install a fresh copy of M2 on the same server your live site is running on. Keep in mind this should be the same version as your live store. Benchmark your fresh copy against your live M2 site. If this fresh copy is significantly faster than your live store, you don’t need to change anything.

If it is slow, then there’s no doubt that your hosting resources are simply not enough to power Magento 2. Get a different plan or sign up for those Magento 2 optimized servers you could find on the web. Also, choose a server location that is in your target market or as close as possible.

Recommendation: How to Choose the Right Hosting for Magento 2?

2. Enable System and Full-Page Caches

Cache management is the key to Magento 2 speed optimization and has a significant impact on performance. The good news is that it can be easily done from the backend. You don’t need to be a Magento 2 expert to configure the system and full-page caches eithers. Just follow the below instructions.

Go to System -> Cache Management. All of the cache types should be set to ENABLED. If they are not, choose “Select All” from the dropdown, Enable, and press the Submit button.

magento-2-speed-optimization

The next time a user visits your website, it will load quickly by retrieving the information from cache.

3. Inspect Third Party Extensions

Third party extensions are one of the most common reasons for a slow Magento 2 site. Either your site has too many extensions installed, or they are poorly coded. Your site will not only have to load the site content but all the extensions also which will significantly affect the loading time.

Your task is to find all the bloatware/redundant/unused plugins and eliminate them. Make an audit of every extension by disabling them one by one. If by disabling an extension you notice a significant difference in speed, you have found the culprit. Contact the vendor for help, find an alternative, or simply uninstall the extension.

You can disable an extension by accessing the server using SSH credentials and running the following command.

php bin/magento module:disable VendorName_PluginName

and to enable it again, replace “disable” with “enable”.

Alternatively, you can uninstall an extension by deleting it from the app/code folder. Run this command after you do this.

php bin/magento setup:upgrade

Do not disable or uninstall an extension which is critical to your store’s functioning unless you have an alternative in place. While trying to fix one thing, you may end up driving your Magento 2 store into the ground. So, we highly recommend letting Magento 2 experts handle this part.

4. Use Optimised Images

Naturally, an eCommerce is store is full of images, videos, and other forms of multimedia. Your M2 site can be slow due to heavy images. Images are heavy content which can seriously slow down your site. To reduce page load time and enhance UX, make sure you use compressed images without compromising the quality.

It is recommended to use product images in WebP format. While JPEG and PNG formats were ideal before, WebP is the norm today. Despite WebP being almost 30% less in size, the quality is the same as JPEG if not better. You can use an extension to auto convert all images to WebP rather than do it manually.

5. Switch to PHP 8

Although Magento 2 supports PHP 5.6 but performance can be improved a great deal by switching to the latest PHP version which is PHP 8.3. You can switch to the latest Php version from the cPanel or manually by adding directives in the .htaccess file of your store: For example, to switch to PHP 8.3, add the following directive.

AddHandler application/x-httpd-php83 .php .php5 .php4 .php3

Note that it will change the PHP version in the subfolders also. Make sure the above PHP version is installed on your server before making these changes. We recommend contacting the server provider before upgrading as you need to ensure the web server is configured to use PHP 8.3.

6. Turn Production Mode ON

Did you know that Magento 2 has three different running modes? These are:

  • Default
  • Developer
  • Production

Most people are unfamiliar with the modes or hesitate to switch between them. However, from an optimisation perspective, it is important to understand the three modes and how to switch between them. The first two modes are for development purposes. They help admins identify issues among numerous other things.

Production mode is the fastest of them all and perfect for a live website. So, if you want maximum performance and fast speed, you need to switch to production mode. Log into your server using SSH and navigate to the root directory of Magento. To find out which mode are you running in, apply this command:

bin/magento deploy:mode:show

To switch to production mode, type

bin/magento deploy:mode:set production

Complete Tutorial: Set Magento 2 Modes - Developer, Default, & Production

7. Minify and Merge JavaScript/CSS

Minification is one of the methods to reduce load time by minimizing the code. Merging JS and CSS files will result in fewer server requests. This feature was absent in Magento 1. To speed up Magento 2, configure these settings in the backend.

  • Go to Stores -> Configurations -> Advanced -> Developer/li>
  • Under JavaScript Settings, Set the Minify JavaScript Files field to ‘Yes’.
  • Now expand CSS Settings and set the Merge CSS Files and Minify CSS Files fields to ‘Yes’. Click the Save Config button and clear the cache.

8. Enable Flat Categories and Products

Reading data from different tables of the database may cause delays. A good idea will be to get frequently read data from different tables and merge it into one easily accessible table. This will reduce the database read time and data will be loaded much faster.

  • Go to Stores -> Configurations -> Catalog -> Catalog and expand Storefront.
  • Set both the “Use Flat Catalog Category” and “Use Flat Catalog Product” to “Yes”.

9. Setup a Content Delivery Network (CDN)

The further you are away from your server, the longer it takes and ultimately the slower the website. If you have customers all around the world which most e-Commerce websites have, setting up a CDN will significantly reduce the amount of distance between the user and the server.

It accomplishes this by setting up CDN endpoints in as many locations around the world as possible. So when a user tries to access the content, it is first retrieved by the content delivery network service and then distributed around the world.

Every user now instead of sending request to the server thousands of miles away, can access it directly from their closest CDN. The result is improved speed.

How to Setup CDN in Magento 2?

  • Log in to your Admin Panel and navigate to Stores -> Configuration -> General -> Web.
  • Expand the Base URLs section.
  • Enter the CDN ULRs for the Static View Files and User Media Files (JavaScript) in Base URL for Static View Files & Base URL for User Media Files respectively.
  • Now expand the Base URLs (Secure) section.
  • Enter the same data in Secure Base URL for Static View Files and Secure Base URL for User Media Files fields.

Save the changes.

For further information, check out our detailed guide on ‘How to Set Up a CDN in Magento 2’. If you are already familiar with the steps, skip to ‘Top 8 Best CDN Providers for Magento 2 ’. We have compiled this list after considerable research to make it easier for store owners to decide which CDN they should use.

10. Update to the Latest Stable Magento 2 Version

Lastly, if your Magento 2 version is not the latest, update it. This is important because the latest stable version will have the newest features and upgraded performance which your store should not miss. Given the highly competitive nature of eCommerce, even slight improvements can help you retain and improve the market share.

You can check your current Magento 2 version by logging into the backend and scrolling down to the bottom of the page. This guide will help you if you want to upgrade to the latest Magento 2 version. We highly recommend that you backup your entire store before updating it.

11. Clear Up Magento 2 Datalog

Most store owners are unaware that all of their product-related data is located in Magento Datalog. Over the time, as a store grows, certain products are removed from the catalog due to various reasons. However, store admins often fail to remove the relevant information from the Datalog.

It means the Datalog is full of unnecessary information. Therefore, it is important to remove all unused information. This can free up valuable space on the server. At the same time, you’ll notice significant improvements in product page loading times. To configure automatic deletion, follow the below instructions:

Go to System -> Configuration -> Advanced -> System and expand MySQL Message Queue Cleanup. Enter the values that are relevant to your requirements. Click on ‘Save Config’ afterwards.

Conclusion

There are many variables involved when it comes to Magento 2 speed optimization. In this article, we have covered some very basic and relatively advanced methods using which you can drastically improve the performance of your Magento 2 store. After implementing the above tips, analyse your website in Goolge PageSpeed Insights again. If you think your Magento 2 is still slow and needs further fine tuning, you can hire our professional Magento 2 speed optimization experts.

This blog was created with FME's SEO-friendly blog