Magento – How to Magento 2 Enable JavaScript Bundling

javascriptmagento2

I merged JS and CSS file Stores -> Configuration -> Advanced -> Developer -> Javascript Settings in production mode of magento2.

Once, I check via view source of the page, I can see the Javascript is merged.

But Still it's show 75 external Javascript scripts via GTMatrix HTTP requests.

So How can i removed that 75 external javascript requests?

Thank you in advance!

Best Answer

Javascript bundling is a technique that groups separate files in order to reduce the number of HTTP requests that are required to load a page. Bundling is commonly used in today’s “module-based” development where some functionalities are basically split into Modules.

From Admin Panel: In Admin Panel go to Stores -> Configuration -> Advanced -> Developer -> Javascript Settings ->Enable Javascript Bundling

detail

From Terminal:

We have to run the following command

For enable:

php bin/magento config:set dev/js/enable_js_bundling 1

php bin/magento cache:clean

For disable:

php bin/magento config:set dev/js/enable_js_bundling 0

php bin/magento cache:clean

Thanks