Cookie Consent addon script enqueued without jQuery dependency, breaks JS when c
-
Cookie Consent addon script is enqueued without the jQuery dependency
In 2.0.5,
addons/cookie-consent/assets/js/an-cookie-consent.jsis enqueued withoutjqueryin the dependency array, so WordPress prints it abovejquery.min.jsin the head. The file’s first statement isjQuery(document).ready(...), which throwsReferenceError: 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$depsargument on thewp_enqueue_script()call for that handle.Reproduced on WordPress 6.x, plugin 2.0.5, WP Fastest Cache with Combine JS enabled.
You must be logged in to reply to this topic.