Magento2: Merge JavaScript Files does not work

Created on 30 Nov 2015  路  3Comments  路  Source: magento/magento2

The configuration value for merging the JavaScript files has no effect.

Environment

  • Magento Version: 2.0.0 CE
  • Webserver: Nginx + PHP FPM

Steps to reproduce

  1. Open the homepage of a Magento 2.0 CE Demo Store (e.g. Magento 2 Developer Hub > MAGENTO 2.0 CE FRONTEND DEMO)
  2. Observe the number of JS requests in your browsers' network tab. About 120 JavaScript files are being requested:
    Screenshot of the Magento 2.0 CE Frontend Demo Store JS Requests
  3. Goto Backend > Stores > Configuration > Advanced > Developer > JavaScript Settings and set Merge JavaScript Files to Yes
  4. Click "Save Config"
  5. Refresh all Caches
  6. Goto the homepage and observe the number of JS requests in your browsers' network tab

Observed Behavior

All JavaScript files are still being loaded separately:

Screenshot Number of JS Requests with JS Merge Enabled

Most helpful comment

Merge JavaScript Files to Yes currently merges only js files added to <head> explicitly.
You can open page source (Ctrl+U). And find that instead of several files (../requirejs/require.js, ../mage/requirejs/mixins.js, ../requirejs-config.js) you have something like static/_cache/merged/26a...e.js.

If you want to reduce number of request to different static files try to set
Enable Javascript Bundling to Yes and setup Magento mode to production.

All 3 comments

You will see the number of requests reduced when Magento is in production mode.

Merge JavaScript Files to Yes currently merges only js files added to <head> explicitly.
You can open page source (Ctrl+U). And find that instead of several files (../requirejs/require.js, ../mage/requirejs/mixins.js, ../requirejs-config.js) you have something like static/_cache/merged/26a...e.js.

If you want to reduce number of request to different static files try to set
Enable Javascript Bundling to Yes and setup Magento mode to production.

It is not an issue.

Was this page helpful?
0 / 5 - 0 ratings