Skip to content

Exclude FrontConsent scripts from WP Rocket's "Delay JavaScript execution" - #28

Merged
davidperezgar merged 1 commit into
mainfrom
fix/wp-rocket-delay-js
Nov 25, 2026
Merged

davidperezgar merged 1 commit into
mainfrom
fix/wp-rocket-delay-js

Conversation

@amulero

@amulero amulero commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Problem

With WP Rocket's "Delay JavaScript execution" enabled, FrontConsent's scripts
don't load until the visitor's first interaction. As a result:

  • The first click on "Accept" / "Reject" does nothing.
  • For returning visitors who accepted, Google tags fire before Consent Mode
    is updated to granted.
  • Leftover tracking cookies are not cleared on page load.

Solution

Use WP Rocket's rocket_delay_js_exclusions filter to exclude FrontConsent's
scripts from the delay. The patterns only match FrontConsent's own scripts;
other scripts stay delayed as configured. Exclusions that are already set are
kept. Without WP Rocket, nothing changes.

Tests

  • New CookieNoticeWpRocketTest (3 tests): every script FrontConsent prints
    is excluded, unrelated scripts are not, and existing exclusions are kept.
    It fails without the change.
  • Full PHPUnit suite, phpcs and phpstan: passing.
  • Manual test on a site with WooCommerce, WP Rocket (delay JS on) and GTM4WP:
    the banner works on the first click, and Consent Mode granted reaches the
    dataLayer before gtm.js.

Notes

  • FrontConsent PRO needs the same fix; it will come in a separate PR.
  • No version bump (left for the release PR).

🤖 Generated with Claude Code

…tion"

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidperezgar
davidperezgar merged commit bd80654 into main Nov 25, 2026
7 checks passed
@davidperezgar
davidperezgar deleted the fix/wp-rocket-delay-js branch November 25, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants