JS errors can often occur when incorporating JS libraries into a bundle. This is because JS libraries have specific dependencies, which can be incorrectly defined and therefore placed in the wrong order, or they may be incorrectly inserted in the bundle structure. This troubleshooting article will help you fix JS errors that occurred after creating JS bundles in the Magento 2 Page Speed Optimizer extension.
How to Exclude JS Files from Bundling
Step 1. Specify the JS file path in the exclusion list
- In the main Magento menu, go to Plumrocket -> Google Page Speed Optimizer.
- In the “Exclude JS Files From Bundling” field, specify the path to the JS files each on a new line in the correct formats described below.
- Click Save Config.
- If the JS file is from Magento and does not belong to any extension, for example:
you should add the two following entries:
Alternatively, you may exclude all JS files from a folder by adding the following entry:
- If the JS file belongs to the extension, for example
then you should use the following format:
Step 2. Apply Changes
Run the following commands to delete the specified JS files and regenerate bundles.
find ./pub/static/frontend/ -type f -name '*requirejs-config*.js' -delete bin/magento setup:static-content:deploy