Written by: Aleš SýkoraThe Author of Toolset.wiki. Big fan of Toolset plugins and WordPress. More info
I am big fan of WordPress and Toolset plugins. I have done many projects based on WordPress. I also have experience with online marketing, PPC advertising and SEO. I live in Czech Budweis – the town of Budweiser Budvar breverage in the south of the Czech Republic – the heart of Europe.
I love skateboarding, snowboarding, frisbee, fitness, healthy lifestyle, tattoos, mountain biking and other sports. I enjoy having time with friends with good beer and good music.
WP Rocket + Toolset Exclude files from Defer JS
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:
validation.js codemirror.js conditional.js recaptcha-v2/api.js
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
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 :-).