Friday 22 May 2015

How You Can Improve Page Speed in Magento 2

All of us are aware that Magento 2 is replete with lots of improvements in terms of features and interactivity apart from security updates as well. But questions on how its page speed can be improved have always remained. Now does speed automatically mean better performance? This leads us to a larger debate on performance and scalability, which are both related but different.

Performance and Scalability

Now, say you want to improve your server performance enabling it to handle some more load. But you may also choose to change the architecture in such as way that your performance is reduced but scalability increased. For instance, a shared or distributed redis cache could be less efficient when compared to running on a single server. But a shared server architecture improves your scalability though it cuts down on  performance. 
 
When it comes to ecommerce, people want sites to be speedy and responsive and so, what often matters the most is the speed at which the page is being rendered in the web browser. As far as Magento 2 is concerned, the Magento PHP server code takes up a third of the time and the remaining time is taken up for the Javascript, CSS files and all other web page components to download. Improving speed, therefore, involves not one but many factors.

Javascript Bundling

To manage Javascript file downloads, Magento uses RequireJS which results in an increased number of download requests. This in turn affects page performance.

The idea here is to bundle the JS files so that we have one request in place of ten. This also includes reducing/compressing the files by removing comments etc. Here you use the modularity features of RequireJS so as to reduce the effort.

This, you would find greatly reduces the page load time without you having to use the original raw files or reworking your code.

Inline Javascript 
 
Removing Inline Javascript can also greatly reduce the load time for the user, making the page appear before the user faster due to the DomContentLoaded event loading two times quicker. The downside though, is that you will need Javascript to fully render a page.

HTTP2 Protocol

This has many features like improved downloading of page assets and allowing the server to transfer files the browser needs before the browser asks for it. In fact, some developers opine that the improvements in HTTP2 will make the use of RequireJS redundant.

So, a combination of the above improvements will no doubt take your page loading speeds higher!

3 comments:

  1. These tips are absolutely amazing. I truly loved all of these details. Even I am going to promote my magento based website and would like to make use of the best form of marketing so that the sales are boosted up. Thinking to get started with SMM and Adwords Management service and hoping to have good results.

    ReplyDelete
  2. Page speed is really very important for website ranking, i got here details idea, thanks.
    i will follow this resources for this website

    ReplyDelete