Exclude files from Load JavaScript Deferred

In some cases, the option Load JavaScript deferred (in  File Optimization →  JavaScript Files) may conflict with a specific file.

If this option causes any problems, you may need to exclude a file from the process. 

You can use the field in the plugin settings to exclude files:

 Exclusions may be done by using any of the following:

  • Full file URLs (with query strings removed)
  • Keywords from the file URL
  • Wildcards

Heads up!

Certain patterns of exclusions cannot be handled and are automatically removed.

If you add them, you should see a notice with the "WP Rocket: The following patterns are invalid and have been removed" message.

Please see more in our Invalid patterns of exclusions article.

Examples

Exclude an externally hosted file

<script src="//maps.googleapis.com/maps/api/js?key=AIzaSyBusRuOn8uzsREWbwi-KCU4puf0me2aj3A&libraries=places" type="text/javascript"> </script>

You could simply use the domain:

maps.googleapis.com

This applies to external files that weren't minified by WP Rocket, and thus, kept their original external domain name.

Exclude a single file

To exclude this file:

https://example.org/wp-content/plugins/elementor-pro/assets/js/frontend.min.js?ver=3.0.5

Use the following:

https://example.org/wp-content/plugins/elementor-pro/assets/js/frontend.min.js

Exclude a group of files

To exclude all files from a specific plugin folder, you could use a wildcard:

https://www.example.org/wp-content/plugins/my-plugin/assets/js/um-crop.min.js?ver=2.1.12

Use the following:

/wp-content/plugins/my-plugin/assets/js/(.*).js

Exclude a minified file

To exclude a file which is also minified, the exclusion has to be based on the minified file URL. So choose a part of the URL (excluding the domain) which is unchanged by minification.

To exclude this file:
https://www.example.org/wp-content/cache/min/1/wp-content/plugins/plugin-name/assets/js/pickadate/picker.time-f9a2f2b5fb728f25892f2f41b6f8a4b9.js

Use the following:

plugin-name/assets/js/pickadate/picker.time

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.