Magento 2 speed optimization is one of the steps every Magento 2 store owner should take when the traffic drops, bounce rates rise and there is no increase in conversion rates. And all this because website performance is a vital factor that influences not only SEO and traffic, but purchasing decisions as well.

Magento is one of the best CMSs out there that people choose for its unique functionality, exceptional features, and, obviously, speed.

Yes, Magento with sample data is really fast.

But as soon as you start to add on extra functionality, customizations and third-party modules, it starts to drop.

Once you test Magento speed, you know what causes slow website performance since most of the speed testing tools provide you concise reports on performance. The next step is to work on these reports to eliminate the issues.

To help you keep your Magento website blazing-fast, we’ve prepared the best tips to speed up Magento 2.

Post Contents [hide]

    1. Update to the latest version of Magento

    One of the first steps you can take when improving the speed of your website is to update your Magento regularly. New releases come along once every three months and bring many new features, bug fixes and, obviously, speed improvements.

    You shouldn’t neglect it and use the outdated versions since sooner or later it is going to result in major issues. Therefore, update Magento often to ensure the fast and streamlined work of your website.

    2. Change Hosting Provider

    Magento is a complex platform that has certain system requirements to function properly. The obligatory requirements are SSL and 2GB of RAM. However, it will vary depending on your website needs.

    It is great to choose a shared hosting that is best for beginners. However, you can’t expect a fast website loading speed with shared hosting and the cheapest hosting plan with limited resources.

    Make sure your hosting provider offers you enough server resources to host a certain number of users and process enough server requests.

    Besides, opt for hosting that provides you an opportunity to scale up. If your current hosting doesn’t satisfy your Magento needs, consider changing Magento hosting provider to speed up your website.

    3. Audit Third-Party Extensions

    Of course, your store can run well with the default Magento functionality. However, oftentimes merchants try to keep up with the latest trends and stand out from the competition by offering exceptional features. This is achieved with the help of Magento 2 extensions.

    While they facilitate some processes, Magento modules add up more code to your website and make it more complex. It can result in speed issues and cause your website to load slower.

    The best solution here is to conduct an audit of your extensions and find the “abuser” you can either optimize or remove completely. It is always recommended to remove Magento 2 extensions you don’t use to make your website lighter and faster correspondingly.

    Here are some useful commands you can use to disable, enable and manage Magento 2 extensions:

    bin/magento module:status
    bin/magento module:enable
    bin/magento module:disable

    4. Use Lightweight Magento Themes

    You might be surprised, but your website theme can also significantly slow down your website, especially if it has a lot of widgets, sliders and custom blocks. Just imagine how much time it will take to load all of them.

    So, it is bad in every sense for website users with good internet connection and a nightmare to the ones with the slow internet. Not only does it result in a bad customer experience, but can influence other Magento features and make things worse.

    Before purchasing a theme, you have to make sure it runs fast on demo and test it with GooglePageSpeed for more detailed analysis.

    5. Delete Unnecessary Fonts

    When you try to provide a better experience for your customers you explore a lot of trendy designs, themes, and fonts. The last ones can reduce the page loading speed even if they are not used.

    Sometimes, it happens that you add some custom font to the <head> section of the page configuration file and forget about it. Regardless if the font is used or not, it will be loaded anyway.

    So, to speed up Magento 2 you can also try to delete unused fonts. GooglePageSpeed suggests it too. Adobe provides you with a comprehensive guide, so it won’t be hard to remove unnecessary fonts.

    6. Optimize Images

    Once visitors come to your website, all of the page content is loaded at once. There are a lot of images of different sizes that will take more or less time to load, causing a delay in page and website loading in general.

    To speed up Magento 2 website, you need to optimize images. One of the best ways to do it — is through lazy loading. It is a method of loading images when they are loaded gradually, while customers scroll down the page. Lazy loading eliminates the need to load all images at once and prioritizes them.

    It results in faster page loading and better customer experience.

    7. Use Next-Gen File Format

    Since images often take a lot of place on your server, lazy loading is not the only option to increase Magento website speed through image optimization. To decrease the size of the images without much quality loss, you need to use WebP images in Magento 2.

    It is a next-gen file format developed by Google and supported by most browsers. It allows you to reduce the file size by 25-35%, retain image quality and improve Magento site speed accordingly.

    WebP Images Test in Google Page Speed

    Since WebP is a relatively new technology, Magento doesn’t allow you to add images already in WebP format to Magento. Instead, you can use an extension like Magento 2 WebP Images to convert images automatically or manually.

    8. Disable Flat Catalogs

    Magento flat catalogs were used to increase Magento website speed due to fewer SQL queries and data consolidation. It worked well for Magento 1.x.x and 2.x.x. It is a fact.

    However, it turned out to be causing the appearance of heavy dependencies and led to performance degradation and the other indexing issues. That is why using flat catalogs is not a good practice starting from Magento 2.1.

    So, one of the ways to optimize Magento speed is disabling them.

    To disable Flat Catalogs in Magento 2:

    1. Navigate to Stores > Configuration > Catalog > Catalog > Storefront.
    2. Disable Use Flat Catalog Category and Use Flat Catalog Product options.
    3. Don’t forget to Save Config once you finish.

    Flat Catalogs in Magento 2

    9. Disable JS Bundling

    JS bundling is supposed to group JS files into big bundles and reduce the number of HTTP requests to the server required to load the page. However, it doesn’t improve Magento site speed, but quite the opposite.

    The website page is not loaded until the browser downloads all of the JS bundles, even if the page uses files from one or two bundles. Moreover, Magento loads JS bundles every time a browser requests a new page.

    And considering JS bundles are around 5-10Mb on average, this is not the best way to improve Magento performance.

    So, the other way to speed up Magento 2 is to disable JS bundling:

    1. Go to Stores > Configuration > Advanced > Developer > JS Settings.
    2. Disable the JavaScript Bundling.

    Disable JS Bundling in Magento 2

    10. Use Advanced JS Bundling

    Since using regular Magento JS bundling is not recommended because of the inefficiency, there is an alternative — advanced JS bundling.

    It allows you to reduce the number of HTTP requests to the server and decrease the size of JS files, the same as the regular JS bundling. However, advanced JS bundling eliminates the need to load all of the bundles, for all pages requested by a browser.

    Each page has a certain set of requireJS dependencies. To satisfy the need of each page you don’t need all of the bundles, just a couple of them.

    Therefore, to enable advanced JS bundling you need to define bundles by page types (CMS pages, product, category, checkout) or purpose (shipping features, check out features, product-related features).

    Since only some specific bundles will be loaded for one page, Magento speed will increase significantly. However, for websites with a deep module structure and many customizations professional configuration might be required.

    11. Enable Deferred JS Loading

    Together with CSS and HTML, there are a lot of JS files loaded during the page load. All of this contributes to slow website loading which neither customers nor merchants like to experience.

    To optimize JS file loading, you can use deferred JS loading. It allows you to execute the JS script after page parsing and increase Magento website speed accordingly. This means all of the scripts will be moved to the bottom of the page, except for the scripts you don't want to move to the bottom.

    12. Merge and Minify JS/CSS Files

    There are some other ways to optimize Magento speed through JS and CSS. Magento has some built-in tools for merging and minifying JS and CSS files.

    Minification allows you to keep your JS and CSS files “clean” by removing unnecessary data like comments, blank lines, etc. This enables web browsers to read them faster and return page requests to the customer faster correspondingly.

    JS and CSS merging on the other hand allow you to reduce the number of HTTP requests to the server by combining JS and CSS files together.

    These two options are known to increase Magento website speed. So, it is recommended to apply them to the website infrastructure.

    Moreover, they are both configured in the admin panel:

    1. Navigate to Stores > Configuration > Advanced > Developer.

    2. Enable the Minify Javascript Files and Merge JavaScript Files in the JavaScript Settings section.

    Merge and Minify JS Files in Magento

    3. Enable the Minify CSS Files and Merge CSS Files in the CSS Settings sections.

    Merge and Minify CSS Files in Magento

    13. Use Critical CSS

    CSS styles define how your store pages look. However, they also definite how fast the page loads. Except for the size of the CSS files and their location, Magento website speed is influenced by the order of their loading.

    CSS styles from external files block the rendering of the page so the page is not displayed until these files are loaded. This causes a significant delay in the speed of page loading, not speaking about the user experience.

    By using critical CSS you define the CSS files that should be loaded first and those which loading can be deferred. This way you eliminate the render-blocking resources and improve the first meaningful paint drastically while non-critical styles are reloaded asynchronously.

    To configure the path to the critical CSS file:

    1. Go to Stores > Settings > Configuration > ADVANCED > Developer.
    2. Enable CSS Critical Path.

    Use Critical CSS in Magento

    The Developer tab is visible only in development mode. To enable critical CSS in production you can run the following command:

    bin/magento config:set dev/css/use_css_critical_path 1

    14. Turn On Production Mode

    If you’re a developer, then you must know that there are three different Magento modes. Production is the fastest one and it should always be enabled on a live website.

    Sometimes websites are not performing as expected since the developer mode is enabled. However, it is only used for debugging purposes. Make sure the production mode is enabled to speed up Magento 2 website.

    Run the following commands to:

    • check what Magento mode is enabled on your website
    php bin/magento deploy:mode:show
    • enable production mode if it is disabled
    php bin/magento deploy:mode:set production

    15. Use CDN

    For Magento 2 stores that sell globally and target customers from various worldwide locations, CDN implementation can significantly improve Magento website speed.

    CDN stands for Content Delivery Network. It is a system of geographically distributed worldwide servers that allows you to deliver content to your website users faster, regardless of their location.

    It is achieved due to the CDN architecture that caches the image, media, JS and CSS files on remote servers. Then, CDN serves these files to users from the server closest to their location.

    Magento has the CDN setup, but you do need to configure it manually. Today most of the web content is delivered through CDN. So, you should consider it to increase Magento speed.

    16. Move to HTTP/2

    HTTP/2 is the upgraded version of HTTP/1 that delivers faster website loading speed. If HTTP/1 creates new server connections for every static file to process, HTTP/2 can do this simultaneously.

    HTTP/2 processes multiple static files in one connection. This way website loads and renders faster since no time is wasted on building multiple connections.

    Although most of the web servers support it by default, you can configure HTTP/2 through your CDN or web server. 

    17. Enable Caching

    When you enter a page for the first time, the server loads its contents and displays them to you. At the same time, Magento makes a copy of the page automatically and caches the page content.

    Then when you revisit the page, the server has to generate the page contents again.

    Cache facilitates this process since it preloads the page content so that the server doesn’t have to generate the page again and wonder how it should look like.

    Sometimes, when a developers or designers work on a website, they disable the Magento cache to work seamlessly. However, if they fail to enable it once they finish, it can result in slow website loading and a bad experience for your customers.

    To speed up Magento 2, make sure all your caches are enabled.

    Go to System > Cache Management, select all caches, Enable All of them and Submit.

    Enable All Magento Caches

    18. Implement Varnish Cache

    When you decide to go more advance with the Magento caching, you’ll come along Varnish. It is an open-source solution recommended by the Magento team. Though Magento already has a built-in full-page cache, Varnish is far more advanced.

    Varnish serves as a web application accelerator that "boosts" HTTP traffic, saves bandwidth, and substantially improves server response time. Moreover, it is used to cache both dynamic and static content.

    If some files are requested frequently, Varnish will cache them into RAM and prioritize them over the other files. So next time these files are requested, they will be loaded blazing-fast.

    Varnish is a robust solution to Magento caching that can increase Magento website speed. However, it gets tricky with the configuration. So, make sure to set it up correctly or consult professionals about it.

    19. Configure Redis

    Another caching solution that comes hand in hand with Varnish cache in terms of usage frequency is Redis. It is a caching tool for the backend that allows you to store sessions and session data. It enables you to have fast access to the user statuses, settings and credentials.

    Redis has a distributed data storage structure and allows servers to move frequently used page content to RAM. As a result of the in-memory data storage, Redis doesn’t require constant disk access. Due to this a number of performed operations increases and diminishes the delay in the search database or API requests.

    Besides, Redis caches not only sessions but web pages, query results, and multiple frequently used objects for better Magento performance and response time.

    20. Update Indexers

    The architecture of Magento allows it to arrange a lot of merchant data (prices, catalog, store, users) into tables using indexers. So indexers is a way to transform and display products and categories data on the storefront.

    Therefore, there is no need to calculate some specific data and make complex MySQL queries in Magento 2 continuously. You’ve got indexers for this. They are reindexed by the core system and you need to make sure they are configured correctly.

    In case you see that some products don't appear or there is a sudden drop in website speed, you can do reindex via CLI or reindex Magento from admin panel.

    Reindex Magento 2 From Admin Panel

    21. Clean Database Logs

    Magento keeps thousands of MBs of data in logs with different data entries. If you don’t clean your logs, the database can grow heavy with unnecessary data and cause delays in responding and processing requests.

    So, it is recommended to clean database logs to improve Magento website speed and reduce delay in loading. However, don’t forget to create a backup before cleaning the logs.

    The list of safe log tables to clean includes:


    dataflow_batch_export;
    dataflow_batch_import;
    log_customer;
    log_quote;
    log_summary;
    log_summary_type;
    log_url;
    log_url_info;
    log_visitor;
    log_visitor_info;
    log_visitor_online;
    report_viewed_product_index;
    report_compared_product_index;
    report_event;
    index_event.

    Magento 2 Speed Optimization Service

    Optimizing Magento speed is not a piece of the pie. It requires time, skills, determination and, most importantly, consistency. 

    From the list above you see that the workload is huge. Yet, it also might not be enough. 

    Sometimes disabling JS bundling, using the latest version of Magento, and optimizing images won't bring you the expected result. Not because you don't do enough. It's because there might be some issues hidden too deep for you to see.

    This is why sometimes it's best to trust your website in the hands of professionals and allow them to optimize your Magento 2 website speed for you. 

    Give us a note right away and we'll discuss the workload together to make your website load fast like a charm.