Stratus Magento 2 Guides - Using Baler to Speed Javascript Delivery
The result of this bundling is faster page speed times, which can improve customer experiences and Google rankings.
Bundling can only be activated on a Production environment.
Installing Baler
To install Baler:
-
Clone the current Baler Repository.
git clone https://github.com/magento/baler.git
-
Change to the Baler directory and install using npm.
npm install
-
Check to confirm you have node.js version 10.12.0 or later.
~/baler/bin$ ./baler baler requires a version of node.js >= 10.12.0. You're currently using v8.16.0
For more on using node.js, see Node.js Node Version Manager.
-
Change to the Magento 2 document root and run Baler.
:~/public_html$ /srv/baler/bin/baler
-
Clear Magento and Redis cache.
~/public_html$ n98-magerun2 cache:clean
~/public_html$ n98-magerun2 cache:flush
~/public_html$ redis-cli flushall
-
Install the Magento 2 module that will handle bundlings.
composer config repositories.baler vcs https://github.com/adifucan/m2-baler
composer require magento/module-baler:dev-master
-
Activate module.
n98-magerun2 module:enable Magento_Baler
-
Run deployment process.
n98-magerun2 setup:upgrade
n98-magerun2 setup:di:compile
n98-magerun2 setup:static-content:deploy
-
Clear Magento and Redis cache again.
~/public_html$ n98-magerun2 cache:clean
~/public_html$ n98-magerun2 cache:flush
~/public_html$ redis-cli flushall
-
Run the set configuration command.
php bin/magento config:set dev/js/enable_baler_js_bundling 1
-
Run Baler again.
$ /srv/baler/bin/baler build
-
Disable builtin Magento 2 javascript minification, merging, and bundling.
php bin/magento config:set dev/js/minify_files 0
php bin/magento config:set dev/js/enable_js_bundling 0
php bin/magento config:set dev/js/merge_files 0
-
Clear Magento and Redis cache yet again.
~/public_html$ n98-magerun2 cache:clean
~/public_html$ n98-magerun2 cache:flush
~/public_html$ redis-cli flushall
Feedback
Was this page helpful?
Glad to hear it! Have any more feedback? Please share it here.
Sorry to hear that. Have any more feedback? Please share it here.