For example, when you have a slideshow on 2 or 3 pages, a modal on one page, etc.
📝 Manual code edit required before use!
📥 Download (.zip): WP Rocket | Exclude JS scripts from Delay JS only at some URLs
Developers: You can find the code for this plugin on GitHub.
- Download the helper plugin zip file, then un-zip it.
- Open the PHP file in a text editor.
- Edit line 35, change the slugs ("first-slug") to the pages where you want to apply the exclusions only. These are the URLs where the scripts won't be delayed. You can add more slugs as needed.
- Re-zip the folder.
- Install the helper plugin on your site - go to Plugins > Add New > Upload plugin and select the zip file.
- Activate the plugin.
- Clear the WP Rocket cache
If you need to exclude scripts based on different rules, you can replace lines 41 and 42 with different conditionals, or add more conditions as needed, for example:
// Exclude scripts at the front page is_front_page() // Exclude scripts at categories is_category()
More information on WordPress conditional tags here: WordPress Conditional Tags