# Keep Critical Scripts Out of WP Rocket's Delay JavaScript

> Excludes scripts you list, such as a consent banner, chat widget or analytics loader, from WP Rocket's "Delay JavaScript execution" so they run right away.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: wp-rocket, javascript, performance
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/rocket-delay-js-exclusions/

## Code

```php
$wpide_keep = array( 'cookieyes', 'complianz', 'googletagmanager.com', 'jquery.min.js' ); // Patterns.

add_filter( 'rocket_delay_js_exclusions', function ( $exclusions ) use ( $wpide_keep ) {
    return array_values( array_unique( array_merge( (array) $exclusions, $wpide_keep ) ) );
} );
```

## Notes

Use part of the script's file name or a keyword from an inline script. Clear WP Rocket's cache after activating.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Critical Scripts Out of WP Rocket's Delay JavaScript" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
