How to Fix JavaScript Errors

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

By adding error-causing JavaScript files to the exclusion list, you will prevent them from being bundled and therefore avoid errors.

Step-by-step guide:

  1. In the main Magento menu, go to Plumrocket -> Google Page Speed Optimizer.
  2. Go to JavaScript Smart Bundling -> Additional Settings tab, and locate the Exclude JS Files From Bundling field.
  3. Specify the path to the JS files each on a new line in the correct format described below.

Supported Formats

  1. 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:

  1. If the JS file belongs to the extension, for example,
    then you should use the following format:

Was this article helpful?