• Cookie Consent addon script is enqueued without the jQuery dependency

    In 2.0.5, addons/cookie-consent/assets/js/an-cookie-consent.js is enqueued without jquery in the dependency array, so WordPress prints it above jquery.min.js in the head. The file’s first statement is jQuery(document).ready(...), which throws ReferenceError: jQuery is not defined, so the cookie consent UI never initialises.

    On its own that only breaks the addon. But any caching plugin that combines JavaScript (WP Fastest Cache with Combine JS enabled, WP Rocket, Autoptimize) merges the files in that same order, and the error then aborts the entire combined bundle, so jQuery core never executes either. Every jQuery-dependent script on the site dies. It only shows for logged-out visitors, since combining is skipped for logged-in users, which makes it hard to spot.

    Fix should be adding array( 'jquery' ) as the $deps argument on the wp_enqueue_script() call for that handle.

    Reproduced on WordPress 6.x, plugin 2.0.5, WP Fastest Cache with Combine JS enabled.

Viewing 1 replies (of 1 total)
  • Plugin Author Yehi

    (@yehi)

    Hi Dan,

    Thank you for the clear report and for explaining how this interacts with JS combining plugins – that was very helpful.

    You’re right: the Cookie Consent script was registered without the jquery dependency. This is fixed in 2.0.6 by adding jquery to the script dependencies so it always loads after jQuery.

    Please update to 2.0.6 and let us know if everything works as expected on your end.

    Thanks again for taking the time to report this!

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.