Title: jquery not defined error
Last modified: August 22, 2016

---

# jquery not defined error

 *  Resolved [mikeaag](https://wordpress.org/support/users/mikeaag/)
 * (@mikeaag)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/)
 * Hey there,
 * I’ve got this plugin installed on a new site that’s currently in development.
 * I am using a custom theme, and a custom version of jQuery.
 * I unregister the built in jQuery and register and enqueue my own version.
 * The issue is that the cookie code –
 *     ```
       jQuery(document).ready(function(){
       	if(!catapultReadCookie("catAccCookies")){//If the cookie has not been set
       		jQuery("#catapult-cookie-bar").show();
       		jQuery("html").css("margin-top","30px");
       	}
       });
       ```
   
 * is being loaded at the start of wp_footer, which is before jQuery is being loaded.
 * By changing
    `add_action ( 'wp_footer', 'catapult_add_cookie_js' );`
 * to
 * `add_action ( 'wp_footer', 'catapult_add_cookie_js', 1000 );`
 * It made the code load after jquery had loaded in the footer.
 * My question is – would it be possible for you to add this to the plugin as default
   or optional behavior?
 * Many Thanks,
    Mike
 * [https://wordpress.org/plugins/uk-cookie-consent/](https://wordpress.org/plugins/uk-cookie-consent/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Catapult](https://wordpress.org/support/users/catapult/)
 * (@catapult)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487228)
 * Hi
 * Just to clarify – is this only happening when you use your theme which is loading
   a custom version of jQuery?
 *  Thread Starter [mikeaag](https://wordpress.org/support/users/mikeaag/)
 * (@mikeaag)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487230)
 * Hey,
 * Thanks for the speedy response 🙂
 * I just installed your plugin on another site which uses the built in version 
   of jQuery and it worked without issue.
 * So it does appear to be due to the fact I am deregistering and then reregistering
   jQuery that’s causing the problem.
 * I can’t see any compatibility issue with applying my fix, but you will have a
   much better idea of if that’s likely to break other people’s installs.
 * Thanks again,
    Mike
 *  [Catapult](https://wordpress.org/support/users/catapult/)
 * (@catapult)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487289)
 * Unfortunately, I’ve never tested the plugin against non-standard versions of 
   jQuery. I’d recommend sticking to the default version.
 *  Thread Starter [mikeaag](https://wordpress.org/support/users/mikeaag/)
 * (@mikeaag)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487374)
 * Thanks for getting back to me.
 * I think I might not have explained myself very well.
 * I am not using a non-standard version of jQuery, i’m just not using the version
   supplied with wordpress. All i’m doing is swapping out the built in version for
   v2.1.1
 * The issue i’m having is a result of loading jQuery in the footer, instead of 
   in the header.
 * The code from the plugin was being loaded and called before jquery had loaded.
   I was able to mitigate this by adding a low priority to the plugin script code(
   as shown in my original post).
 * As its quite a simple fix, i thought i would ask if you were able to add it into
   the plugin. All the fix does is cause the plugin script to load later in the 
   wp_footer action. Because of this, it shouldn’t have any negative side affects
   for anyone, as most people will have jQuery loading in the header anyway.
 * For those of us who have chosen to load jQuery i the footer, this fix will do
   the job.
 * If it’s not something your willing to put into the plugin, then thats not a problem
   and will find a different way to make it work on my site and close this thread.
 * Many Thanks again, the plugin is awesome 😀
    Mike
 *  [Catapult](https://wordpress.org/support/users/catapult/)
 * (@catapult)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487396)
 * Thanks. I think I probably wouldn’t call it a fix, more a feature request, as
   it works fine with the version of jQuery shipped with WP (which is what I meant
   by standard version). So unfortunately it’s not something we’re likely to implement.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘jquery not defined error’ is closed to new replies.

 * ![](https://ps.w.org/uk-cookie-consent/assets/icon.svg?rev=2567699)
 * [Termly - GDPR/CCPA Cookie Consent Banner](https://wordpress.org/plugins/uk-cookie-consent/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/uk-cookie-consent/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/uk-cookie-consent/)
 * [Active Topics](https://wordpress.org/support/plugin/uk-cookie-consent/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/uk-cookie-consent/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/uk-cookie-consent/reviews/)

## Tags

 * [cookie](https://wordpress.org/support/topic-tag/cookie/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [not defined](https://wordpress.org/support/topic-tag/not-defined/)
 * [priority](https://wordpress.org/support/topic-tag/priority/)
 * [wp_footer](https://wordpress.org/support/topic-tag/wp_footer/)

 * 5 replies
 * 2 participants
 * Last reply from: [Catapult](https://wordpress.org/support/users/catapult/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/jquery-not-defined-error/#post-5487396)
 * Status: resolved