Question

Magento 2 website speed very slow as per https://developers.google.com/speed/pagespeed/insights/

Result of site:-

Reduce server response times (TTFB) - 1.68 s
JavaScript execution time - 2.9 s

enter image description here Almost 250 request sends to server. So, google page speed gives 4/100 for mobile and 46/100 for desktop.

We already enabled minify js, merge js, minify css and merge css from backend. Also, HTTP2 protocol used to send all request. We use built in cache in production mode.

We do not use Bundling because its create almost 7.5 MB file so takes more time to load resources.

Please help me to improve page speed around 85/100 for desktop at-least.

Was it helpful?

Solution

I see you tagged LiteSpeed, are you using LiteSpeed web server? If yes, you can take advantage of LiteMage cache to replace Magento built-in cache. The LiteMage starter option has no extra cost. Many LiteSpeed users are using this solution for their Magento 2 stores and are very happy with the results.

OTHER TIPS

Some important points for speeding up Magento 2::

  • Production Mode
  • Full Page Cache
  • Minify JS and CSS
  • Check TTFB and try to reduce it
  • Enable Flat Categories and Products
  • Enable GZIP compression
  • Never Use JS bundling
  • Upgrade to latest(stable) PHP version
  • Use Varnish Cache instead of built in Magento cache. (optional)
  • Image optimization
  • Check every 3rd-party extensions (Avoid conflicts between 3rd party extensions)
  • Upgrade hosting to fasted server
  • Check code SQL query execution time (optimize queries)
  • Enable profiler and check the time.
  • Use CDN (Content Delivery Network)
  • Check your website speed in waterfall

May be this link will help you in details:

Someone has previously touched on CDN but if you have the budget I recommend worldwide distribution system like Cloudflare. Their edge cache and features such as RailGun/Rocketloader offer huge improvement. This plus the worldwide distribution helped us loads on a busy site.

In my experience the more caches in place the more time is spent in development punching holes through the cache getting dynamic content to load. You can handle this in Cloudflare with page rules but they soon add up. Plus all the extra development time required. So choose wisely.

That said a Magento store that loads in under 5 seconds is a fast one. Magento by it's very nature is slow.

Increase the Magento 2 Site Speed by the following ways

  1. Use of Profiler to check the time taken for files to load, especially for third party modules and your custom modules. Check and ensure to load them in lesser time.

    php bin/magento dev:profiler:enable html

    php bin/magento dev:profiler:enable csvfile

  2. Minify your HTML, CSS and js files.

  3. Merge your CSS and JS files.

  4. Optimize and scale your images.

  5. Switch your website to production mode.

  6. Make sure you compress your files through Gzip.

  7. Optimize your server to reduce the server response time.

  8. Check if bundling works to reduce the loading time if it increases the page size disable it.

  9. Also, try using Google Page Speed Module in your Server so you can configure it in the best way to load your site in short span of time. You can also optimize and convert images to best fit for your site.

Since you have tried all sorts of optimization, I believe it will be difficult for you to enable profiler and optimize the code.

I would recommend you to install Google Page Speed Module in your server where you can configure the optimization to speed up the page as well as increasing your google page speed score significantly even 100/100. To see if this can solve all your problems https://developers.google.com/speed/pagespeed/module/

If you are using apache, it will be easy for you to install and configure whereas for nginx it would require more knowledge for setup.

Please follow the points mentioned on Above answer of #Saphal Jha.

Further more follow the following points.

  1. Make sure any block has not configured cacheable=false in any layout xml for given page. because it prevents whole page from full page cache.

  2. You can use magento profiler or Mgt-developer toolbar to debug execution time for each block and collection queries.

  3. Make sure there are not that much use of object manager to create instances in template files (.phtml).
  4. Based on profiler or dev toolbar try to reduce execution time for particular block or collection (it may happen there is select * queries or multiple queries are there which may unnecessary).

Your server response is slow, you need to speed up that. The best and easy way to speed up the magneto website is page cache. But beside page cache, you can do the following to improve server response.

  1. Inspect every installed 3rd-party extension, and disable useless extensions on your website
  2. Choose the fastest hosting you can afford
  3. Turn Production Mode On
  4. Never Use JS Bundling enter image description here
  5. Enable CSS/JS Minification enter image description here
  6. Last and most importantly, enable profiler and check all the files (.phtml) and events, check which are taking more time to execute. And remember even 0.5 sec for a file or event is also huge time for a single file/event.

Gaining a high Google PageSpeed Insights score is never a one-second thing.

There are many opportunities that you have to keep in mind to boost your performance:

  • Eliminate Render-Blocking Resources
  • Avoid an Excessive DOM Size
  • Serve Static Assets With an Efficient Cache Policy
  • Minimize Main-Thread Work
  • Properly Size Images etc.

Here is the guide written by a Magento development team that will help you: https://onilab.com/blog/magento-google-pagespeed-insights-optimization-guide/

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top