Magento – Magento 2 – Heavy loading time (too many js files)

javascriptmagento2performance

I'm currently working on Magento 2 and I noticed that loading times for all the pages are extremely high.

I'm running on Xampp at the moment, production mode enabled, HTML/js/CSS are merged and minified, Varnish is disabled and I will not use it since my web hosting can't install it on my server because it will interfere with some scripts.
I use a custom theme which parent is the blank theme of Magento 2.
After changing my settings I redeployed static files and emptied the cache.

My main concern is that when I look at the network panel I see that a huge amount of js files is loaded every time.
For example on my category page, 122 js files are loaded which I found is quite a lot, for a total size of 955 ko.

I tested it on my server without the merging and minifying but as I said above, I think the issue lies with the amount of file loaded because even if it loads faster it's still too long and on the checkout process it's even worse.

I tried the bundling option but it generates an 8MB js file which is worse.

Did I miss something or is it somewhat normal that the amount of js files is this much? Is Varnish mandatory for good performance and is there an alternative to it?

I'm fairly new to Magento 2 so if you need more info I will be happy to provide it.

Best Answer

The amount of JS is huge, but if it sums up to 8MB there's something wrong. You should use the "Bundling" configuration in production mode if you don't want >100 files loaded.

With the default Luma theme, bundling, merge and minify enabled, the bundled JS file is 1.9MB.

Varnish is another topic and won't help with performance of generated static files.

Related Topic