WORDPRESS - Oxygen - toolset

WP Rocket + Toolset Exclude files from Defer JS

Author: Aleš Sýkora, 6. 11. 2019

If you use WP Rocket + Toolset (especially Toolset forms) you should exclude deferring some scripts. If you use Forms than it is a must. Without excluding you get some errors in console, like this one:

The scripts are:


For excluding you need small plugin from WP Rocket. You can found it here: https://docs.wp-rocket.me/article/976-exclude-files-from-defer-js

Click on this image to open a GitHub repo of plugin

After downloading and installing this plugin, go to /wp-content/plugins/wp-rocket-static-exclude-defer-js and open wp-rocket-static-exclude-defer-js.php in code editor.

Now you must change the URL /wp-includes/js/jquery/jquery.masonry.min.js to URL of script you want to exclude from defer.

$excluded_files[] = '/wp-includes/js/jquery/jquery.masonry.min.js';

change to: 

$excluded_files[] = '/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/js/validation.js';
$excluded_files[] = '/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/visual-editor/res/js/codemirror/lib/codemirror.js';
$excluded_files[] = '/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/js/conditional.js';
$excluded_files[] = '/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/js/recaptcha-v2/api.js';

Save the file, clear the cache and everything works fine again :-).