Add Filter to Customize Pattern in DelayJS Script Injection
Is your feature request related to a problem? Please describe. A user reported that he's frustrated how WP Rocket's inline script is moved directly after
, causing conflicts with Cookiebot and Gravity Forms. This issue occurs due to the hard-coded pattern in the following file:/inc/Engine/Optimization/DelayJS/Subscriber.php, function add_delay_js_script
Describe the solution you'd like
The user is proposing a filter to customize the pattern used for injecting the inline script. Specifically, changing the line: $pattern = '/<head[^>]*>/i';
to: $pattern = apply_filters('add_delay_js_script_pattern', '/<head[^>]*>/i');
This would allow to override the pattern with our own, such as: /<script id="Cookiebot".*<\/script>/i
The user tested this locally and resolves the problem.
Describe alternatives you've considered
Additional context hs: https://secure.helpscout.net/conversation/2614704937/494991?folderId=5547167