Skip to main content

Poor performance is the biggest killer of eCommerce revenue. This is especially important for such resource-heavy platforms like Magento. You may have a sound infrastructure, rich features, but it’s worth nothing if your online store is slow.  In this article, we’ll share easy-to-go tips on Magento 2 Performance Optimization.

Disable Unused Extensions 

There is no doubt that extensions enhance the functionality of online stores, boost SEO and user experience. However, you may not need all of them at the same time. If you want to improve your performance, you can reduce the amount of JS, CSS, and other elements that slow down your website’s speed by disabling modules you’re not using.  

There are several ways to disable third-party modules: 

  1. Via the command line using the ./bin/magento module:disable -c module_name command (-c stands for cleaning generated static view files). Disabling a module by the command line assures nothing related to it loads onto the store.  

    Example: ./bin/magento module:disable -c Amazon_Payment Amazon_Login Amazon_Core
  2. Via the Admin Panel. You can disable third-party functionality in its settings. Although the functionality of a module will be shut down, its certain elements may continue to load on the front end (e.g, CSS). 

Update Your Magento Version

Each new Magento release comes with fixes, platform improvements, and performance enhancements. The last two Magento updates (2.4.2 and 2.4.3) included code enhancements that boosted API performance and decreased indexation time for Product Price and Catalog Rule indexers. After Magento 2.4.3 release, online merchants can exclude a website from a customer group or shared catalog, which reduces the number of records for indexing and improves indexing times. Moreover, the updates include compatibility updates with the latest version of various tools like ElasticSearch. If you want to read more about the last release note, check Magento 2.4.3 Release Notes Highlights

Haven’t Updated Your Magento Store Yet? 

Minify CSS/JS

Minifying the CSS and JS files is an important element of Magento 2 speed optimization. By minifying them we remove all the spaces, tabs, and newlines in the files. The resulting files will have fewer characters and thus a smaller size, so they will download faster. Magento has this feature built-in, so you can enable CSS/JS minification in the Admin area.

To enable CSS minification, follow the next steps:

  1. Switch Magento to developer mode (CLI command: php bin/magento deploy:mode:set developer)
  2. Go to Stores > Configuration > Advanced > Developer > CSS Settings
  3. Set Minify CSS Files option to Yes
  4. Save Config
  5. Flush Cache at System > Cache Management page

Magento-2-CSS-Minification Magento 2 Performance Optimization: Practical Tips

To enable JavaScript minification, follow these steps:

  1. Switch Magento to developer mode (CLI command: php bin/magento deploy:mode:set developer)
  2. Go to Stores > Configuration > Advanced > Developer
  3. Set Minify Javascript Files option to Yes
  4. Save Config
  5. Flush Cache at System > Cache Management page

Magento-2-JS-Minification Magento 2 Performance Optimization: Practical Tips

Don’t Use JS Bundling

JS bundling is a Magento 2 feature that groups JS files together to lower the number of HTTP requests a web browser needs to make to load a page. It is supposed to make a site faster over HTTP version 1 but it has became since HTTP version 2 release. In addition, JS bundling is also useless for one more reason. This huge bundled JavaScript slows the store down.

Go to Stores > Configuration > Advanced > Developer > Javascript Settings and set Enable JS Bundling to NO (screenshot above).

Optimize Images 

The size of your images influences the performance of your website. For example, if there are 30 products on your catalog page and each product image is 1Mb, a server needs to load an additional 30 Mb. You might think it’s not that much. However, it may be an issue for users who have poor internet connections or shop via mobile devices. The more unoptimized images you have, the longer it takes to load your website. All pictures on your website should have a good ratio between quality and size.

Also, you can consider implementing lazy loading, which means loading images after the page load. This feature also can load pictures while users scroll through the website pages. In other words, the browser won’t load the images until they’re in the user’s viewport (until the user scrolls to them). Lazy loading keeps the number of loaded elements at once to a minimum, decreasing the page size and speeding up the overall loading.

One more Magento 2 performance optimization tip is to use a content delivery network (CDN). CDN is used to reduce the server load by caching the site’s content. It places servers at the exchange points between different networks to improve speed and connectivity. These exchange points are the primary locations where Internet providers connect to provide each other access to traffic originating on their networks. A CDN provider can reduce costs and transit times in high-speed data delivery.

Choose a Good Hosting Partner 

Magento is a powerful eCommerce platform that is famous for its scalability, flexibility, and international sales. However, you won’t make the most of it without a good hosting provider. Choosing the wrong provider for a Magento store can lead to serious technical issues or website drop. Our team recommends choosing a dedicated Magento 2 Hosting. Usually, they are the fastest ones and use auto-scaling technologies, which allows online stores to work under heavy traffic.

The easiest way to secure your hosting environment is to choose an official Magento hosting partner. These companies have vast Magento experience, which ensures providing technical support during the installation and deployment processes.

Top Magento 2 Hosting Providers 

Nexcess 

Nexcess is one of the most preferred managed Magento Cloud hosting providers. It’ll help you scale, accelerate, and expand your e-commerce store with its impeccable features. Moreover, they have a talented, dedicated team of support staff that knows the ins and outs of Magento, and they’ll literally set things up for you if you encounter any roadblocks.

JetRails 

The best thing about JetRails is that they operate as your in-house operations group. They have a dedicated team devoted to your infrastructure and will interface directly with your developers and project managers. Working with JetRails is like annually reinvesting millions of dollars in infrastructure operations, hardware and facilities.

CloudWays 

Cloudways offers to host Magento for all kinds of users. It has separate products for agencies, merchants, developers, and startups. Using its own speedy content delivery network, Cloudways delivers fast cloud hosting to all of its customers. Cloudways uses the ThunderStack caching formula to guarantee fast loading time for e-commerce stores built with Magento.

Performance Optimization for Magento | Adobe Commerce®

Use Varnish for Full-page Cache

When enabling full-page cache, use Varnish to handle it, not files. Magento strongly recommends using Varnish (or Redis) in production. The integrated full-page caching (to either the file system or database) is much slower than Varnish, and Varnish is designed to accelerate HTTP traffic. 

Official Magento Guide on Varnish Configuration and Use

To configure Magento to use Varnish log in to the Magento Admin as an administrator:

  1. Go to Stores > Configuration > Advanced > System > Full Page Cache
  2. From the Caching Application list, click Varnish Caching
  3. Enter a value in the TTL for public content field
  4. Expand Varnish Configuration and enter the specific information about your Varnish configuration

Magento-2-Varnish-Configuration Magento 2 Performance Optimization: Practical TipsClean Log Database  

If your store is quite old, database logs can grow to hundreds of MBs with millions of data entries. This clutter will slow down Magento and can even create a space shortage if your disk is already full to the brim. For this reason, you should optimize your Magento MySQL database.

Cleaning Logs via Admin Panel 

This straightforward method is useful for non-technical store owners who do not want to directly work around with the Magento stores database. You can follow the following steps to perform a complete Magento database cleanup of logs:

  1. Go to System > Configuration
  2. On the left-hand side, under Advanced, click on System (Advanced > System)
  3. Under System, you see MySQL Message Queue Cleanup
  4. Set the values for all of these attributes: Successful Messages Lifetime, Retry Messages In Progress After, Failed Messages Lifetime, New Messages Lifetime
  5. Click “Save Config”.

Magento-2-MySQL-Cleanup Magento 2 Performance Optimization: Practical Tips

Nikita Shkurd

Nikita Shkurd

Nikita is a Partnership Manager at Mobecls and a newsmaker/streamer at home. Thinks that the best opportunity in his job is to help businesses get out of hopeless situations.