Title: jQuery is not defined &#8211; solution
Last modified: August 31, 2016

---

# jQuery is not defined – solution

 *  Resolved [opr18](https://wordpress.org/support/users/opr18/)
 * (@opr18)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/)
 * I am getting the jQuery is undefined error.
 * I found the solution to be changing line 29 of public/class-ctcc-public.php to
 * add_action ( ‘wp_footer’, array ( $this, ‘add_js’ ), 999 );
 * Could this be added into the next version to stop this error happening for people.
 * Thanks.
 * [https://wordpress.org/plugins/uk-cookie-consent/](https://wordpress.org/plugins/uk-cookie-consent/)

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

 *  [Gareth](https://wordpress.org/support/users/catapult_themes/)
 * (@catapult_themes)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942614)
 * Hi
 * I don’t think this is related to this plugin. I suspect it might be a different
   plugin or your theme?
 *  [MattPurland](https://wordpress.org/support/users/mattpurland/)
 * (@mattpurland)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942831)
 * Hi,
 * opr18 is correct. The script (add_js function in this case) is injecting the 
   javascript before any queued javascript files. This produces the following scenario
   as part of wp_footer() (tidied up for eligibility):
 *     ```
       <script type="text/javascript">
       	jQuery(document).ready(function($){
       		if(!catapultReadCookie("catAccCookies")){ // If the cookie has not been set then show the bar
       			$("html").addClass("has-cookie-bar");
       			$("html").addClass("cookie-bar-bottom-bar");
       			$("html").addClass("cookie-bar-bar");
       		}
       	});
       </script>
       <script type='text/javascript' src='<domain></wp-includes/js/admin-bar.min.js?ver=4.4.2'></script>
       <script type='text/javascript' src='<domain>/wp-content/themes/<theme>/bower_components/jquery/dist/jquery.js?ver=2.1.1'></script>
       ```
   
 * This is due to the lack of priority on the action for add_js. Setting the priority
   of the jquery enqueue in functions.php doesn’t work, so the only solution is 
   to add priority to the plugin add_action as per opr18’s suggestion.
 * Plugin author: I’d recommend adding priority 1000 to all actions in init() as
   per add_notification_bar to avoid this issue.
 *  [Gareth](https://wordpress.org/support/users/catapult_themes/)
 * (@catapult_themes)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942832)
 * Okay, I will take another look.
 *  [Rubas](https://wordpress.org/support/users/rubas/)
 * (@rubas)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942838)
 * I confirmed that by giving the add_action ( ‘wp_footer’, array ( $this, ‘add_js’));
   priority 900, works.
 * Please add the priority to the next update.
    Thank you 🙂
 *  [Gareth](https://wordpress.org/support/users/catapult_themes/)
 * (@catapult_themes)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942839)
 * Okay – this priority has now been added.
 * Thanks to everyone for their contribution.

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

The topic ‘jQuery is not defined – solution’ 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/)

 * 5 replies
 * 4 participants
 * Last reply from: [Gareth](https://wordpress.org/support/users/catapult_themes/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-solution/#post-6942839)
 * Status: resolved