Magento 2 Advanced Js Bundling

The question:

Can anyone work on Advanced JS Bundling?

We would like to apply this concept to one of our client projects.

Could you please explain about Advanced JavaScript bundling in detailed step by step & is there any tools (or) modules need to be installed for verify?, Is it possible to implement advanced JS Bundling in Magento/2.2 (Enterprise)?*

Note: I followed M2developer Docs but unable to understand & implement. Could you please guide me & would like to know what are the challenges are going to handle?

Is there any difference between JS bundling and Advanced JS bundling?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I did R & D on this task and prepared some implementation notes it might help you others if you would like to do, please follow the below steps on

Advanced JS Bundling.

A) Required Tools

  1. node.js >= 8.x
  2. npm >= 6.x
  3. Magento 2 DevTool
  4. Git

B) DevTool Installation

  1. Clone the repository in your local machine
    Ex: git clone
  2. Run npm install
  3. Run npm start (or)npm run build
  4. Navigate to chrome://extensions
  5. Enable Developer mode
  6. Click Load unpacked
  7. Select the extension folder in the root of this repository
  8. Close & reopen chrome browser

Magento 2 Advanced Js Bundling
enter image description here

C) Usage of DevTool

  1. Visit any page in the storefront in a browser with this extension installed

  2. Open RequireJS >> Bundle Generator

  3. Click the Record button

  4. Begin navigating to critical pages of your store (Home/Catalog/Product/Cart/Checkout)

  5. Click the Record button again when you are finished

  6. Follow the installation instructions in the Bundle Generator UI

Please refer below link for the usage of DevTool taken an example from default Magento 2.3.1 here

D) Setup Instructions

  1. Install the Magento_BundleConfig module: This module is currently not consumable via the composer. Manually install the Magento_BundleConfig module from Github. Make sure you’ve run setup: upgrade and that the module is enabled.


2.Set Store to Production Mode: php bin/magento deploy:mode:set production

3.Backup Static Content Source: For the theme that you are bundling, move each language folder to a folder of the same name, appended with _source.

For example,
if you’re bundling Luma in English, move frontend/Magento/luma/en_US to frontend/Magento/luma/en_US_source.

Just rename en_US to en_US_source

  1. Install the RequireJS Optimizer: You must have node.js installed locally/Server. Run npm install -g requirejs

  2. Save the Generated Bundle Config: Click Copy to Clipboard in the Bundle Generator tab. Save the entire configuration in a file called build.js in the root of your store. (You have seen how to get build.js from the above video reference link)

r.js -o build.js baseUrl=”pub/static/frontend/Magento/luma/en_US_source/” dir=”pub/static/frontend/Magento/luma/en_US/”

r.js -o build.js baseUrl=”pub/static/frontend/Demo/Learning/en_US_source/” dir=”pub/static/frontend/Demo/Learning/en_US/”

If the above steps have been performed correctly, your store should now be running with optimized JavaScript bundles.

enter image description here

Method 2

My website is running at Magento 2.4.2 at ubuntu server.
I have followed all of the steps and Advanced bundling completed successfully. but there is some js errors occur.

The Menu and many other Js is not working After advanced bundling.

Here is the JS error:

  1. //#;/**
  • Copyright © Magento, Inc. All rights reserved.
  • See COPYING.txt for license details.

This Always shows undefined * error.

  1. Uncaught TypeError: require.config is not a function

Advanced bundling works fine with disable js Merge. But, at google speed % didn’t increase.

Please help. how to fix the Js error.


Method 3

If your Magento store is in production mode then

Magento ≥ 2.2 It can be done by the command line

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

Magento < 2.2

UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/js/enable_js_bundling';

Then run this command php bin/magento cache:clean

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment