Are you feeling trapped in WordPress jquery errors? Do you want to fix the “Uncaught ReferenceError: jQuery is not defined” in WordPress website? Then, let’s see how to identify and finally, remove this error.

JavaScript is used for anything from inducing interactivity into WordPress page like hovers to create animation and effects. Whatever fancy functionality you see on WordPress page, comes from JavaScript. Though it is very popular to provide flexibility, runtime errors are very common with this. One of the most common JavaScript errors in WordPress is – “jquery is not defined”. It makes things stop or not working on your WordPress site. Here at Templatetoaster WordPress theme builder, let’s see the causes of this issue and procedure to fix it in detail.

Common Causes of getting “Uncaught ReferenceError: jQuery Is Not Defined” in WordPress

There are some common causes that you encounter the error “jquery is not defined” in WordPress. These are as follows:

  1. One of your plugins is conflicting with other plugins, especially with older ones.
  2. JavaScript runs before the page is fully loaded in turn before the jQuery is fully loaded.
  3. CDN-hosted jQuery might be blocked or down.

Due to these, you get problems like some of your plugins are not working, slider animations are not playing and much more. So, you need a good solution to fix this issue. Here at Templatetoaster web page maker, Let’s see what you can do to get rid of this problem:

Solution to the Error “Uncaught ReferenceError: jQuery is not defined”

Once you get to know the pinpoints, you can see the source code by pressing Ctrl + U. it will open a new window to display the source code. Here, you can easily find the occurrences of the “jQuery”. And, you can further fix this error by following this approach:

Steps to fix jQuery is not defined error

Step 1: Inclusion of jQuery Library

When you go through code, make sure that jQuery is included and will load before your script. Even, the jQuery should be loaded once only. If it is loading multiple times, it will cause problems.

If it is not included, then pass it as third argument in your wp_enqueue_script () function as follows:

wp_enqueue_script( 'tt-mobile-menu', get_template_directory_uri() .

'/js/mobile-menu.js', array('jquery'), '1.0', true );

Step 2: Structure of JavaScript File

Secondly, you will make sure that your JavaScript will start as follows:

jQuery(document).ready(function()

{

jQuery(#selector) ...

});

Alternate:Wrapping the Code in a Function

If you want to go with default “$” symbol, you can wrap the code within a function as follows –

(function($) {

// Use $() inside of this function

$(#selector) ...

})(jQuery);

Step 3: Ensure that jQuery is Loaded

Sometimes, there are issues because the jQuery is not loaded though included. So to make sure that jQuery is loaded, copy the URL from script src and paste it in the new browser tab. For example: If the script src is this:

<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>

You will copy only the http://code.jquery.com/jquery-1.11.2.min.js URL and open it in a new browser tab. It will show you the content of jquery file if it is loaded correctly.

If still having problems, then there must be an error in your code. So, check it thoroughly.

Voila! you are now ready to fix jquery not defined error – Conclusion

So, here at Templatetoaster offline website builder, a probable solution is discussed to fix the jQuery is not defined error. This can’t be said an optimal solution as it’s not easy to spot the exact cause of the issue. But most of the times, this solution works out well. This was all about removing a common error in WordPress-”jQuery is not defined” after identifying its causes. This simple procedure will take only some minute changes in a fraction of time and you are good to go!!

Hope this will help you out !! If you have any queries, you can post in the comment section below.