Whether you're a stranger to WordPress errors or not, being met with "jQuery is not defined" while working on your website is never fun. It can be a startling and confusing message to see. Luckily, this is a standard error that sites using jQuery may experience at some indicate or some other.

Maybe your site is down, and when you check your browser console for errors, yous see "jQuery is not defined." Finding the error is the first step — then well done!

The next footstep is to resolve information technology. Considering this is 1 of the more straightforward JavaScript errors to fix, information technology shouldn't take you very long at all.

In this postal service, we'll walk you through everything y'all need to know to fix information technology fast. That includes what the mistake means, why it may have happened in the starting time identify — all disquisitional information to forbid this error in the future. Finally, we'll walk y'all through a few steps you tin can take to resolve it.

Let's dive in!

Check Out Our Video Guide to Fixing the "jQuery Is Not Defined" Error

What Is the "jQuery Is Non Defined" Mistake?

The handy console log in your browser is where you'll probably discover this mistake. Just it'southward not incredibly descriptive. What does "jQuery is not divers" actually mean?

In plain English, this error is trying to tell you that something on your site — may be a plugin — requires jQuery to function on your site. For some reason, when the browser tried to load the website and called for that specific jQuery, it was non available.

This error tin potentially shut downward your site to visitors. Because roughly 78% of the websites on the internet run on jQuery, this is a common error to find.

The Chrome dev tools console tab will read "jquery is not defined" in red
jQuery is not divers" error in the console log.

Whether y'all're a stranger to WordPress errors or not, being met with "jQuery is not defined" while working on your website is never fun. 😫 Learn how to fix information technology here! ⬇️ Click to Tweet

Potential Causes of the "jQuery Is Not Defined" Error

This error tin exist quite a surprise. Your site was working just fine yesterday — what happened? This might exist a scrap of a head-scratcher.

There are a few possible things that could have occurred that threw the "jQuery is not defined" error:

  1. Onetime plugins installed on your WordPress site are alien with ones that you installed and activated more recently. If you lot recently installed or activated new plugins or some of the plugins on your site have non been updated recently, this may be the cause.
  2. A tedious or poor-performing hosting environment could increase the corporeality of time information technology takes your jQuery to perform when called. Double-check your server resources or error log to confirm this.
  3. The JavaScript on your website is running before the jQuery is fully loaded. Or perhaps a JavaScript file is not being correctly loaded when the page loads.
  4. The CDN that yous're using to improve your site performance was unable to reach your server. If you're not using a CDN at all, you can rule out this possibility entirely.
  5. There'south an fault or typo in your version of jQuery. Perhaps someone recently edited a core file or a plugin, which has at present caused a conflict.

How To Prepare the "jQuery Is Not Defined" Error

Before we swoop into the fix, call back to make a fill-in of your website before editing code! Even the virtually seasoned developers make mistakes now and again, and having a fill-in on mitt volition foreclose you from losing any of import piece of work equally you lot troubleshoot.

If you have the selection, resolve the error on a staging or development site kickoff, equally Kinsta customers do, then confirm the fix and push those changes live.

Once you've taken those necessary precautions, it's time to fix that error.

Resolving this fault takes some familiarity with adding, removing, and editing code. Don't worry — you won't need to write any lawmaking from scratch. But it would aid if you lot were prepared to access your site'south code, either through SFTP or through your hosting environs.

It's not ideal for editing code through the WordPress dashboard lawmaking editor. If yous don't already accept a proficient text editor handy, now's the time to install one.

Here are a few options you can apply to resolve this mistake and get your site back upward to visitors.

Method 1: Utilize the Network Tab to Debug if jQuery Is Loading

Look at the Network tab of your browser'south dev tools to see if jQuery is beingness loaded. This gives you one place to notice a quick validation.

Subscribe Now

The alternative is looking through multiple plugins and themes that could be causing the fault. Become through the code of your site and ensure that jQuery is included. It would exist all-time if you only loaded it once.

If the jQuery library isn't included, add together it to your wp_enqueue_script() function with the following snippet:

wp_enqueue_script( 'tt-mobile-menu', get_template_directory_uri() .
'/js/mobile-menu.js', array('jQuery'), 'one.0', true );

Locate this code by going to the wp-includes folder, and so open the script-loader.php file. If this doesn't piece of work, or if you lot find that the jQuery library is, in fact, already included, motility on to the following method.

Snippet can be pasted into any FTP editor, so long as it's in the script-loader.php file.
How your snippet volition await in the script-loader.php file.

Method 2: Make Sure jQuery Is Loaded

You may experience the "jQuery is not defined error" when jQuery is included but not loaded. Make certain that it'due south loaded by finding the script source and pasting the URL in a new browser or tab.

For example, if the <script src= is set to this:

Your snippet of text should look like this in your code editor.
The snippet of text you should expect for to discover the URL to test.

And so, copy and paste the http://code.jquery.com/jquery-ane.11.two.min.js portion into a new window or tab. If the jQuery file loads and shows you lot the entire contents, you tin can check this off your list.

Method iii: Include Google-Hosted jQuery With a Local Fallback

This is a corking selection to include with your JavaScript considering running jQuery on the localhost may improve your website experience overall. It will assistance avoid whatsoever other CDN jQuery loading problems.

// Fall back to a local copy of jQuery
window.jQuery || certificate.write(''))

With the note at the beginning, this is what your snippet of code should look like.
This is what your lawmaking snippet should expect similar in your code editor. Don't forget the annotation!

Method 4: Add a Snippet to wp-config.php File

If none of the above work, open upwards the wp-config.php file and paste in the following snippet in its entirety:

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
define('CONCATENATE_SCRIPTS', false);

Once added to the wp-config.php file, this is what your snippet will look like.
What the snippet will look like in your wp-config.php file.

Method v: Insert the jQuery Library Manually

As a last method, you tin can go directly into the header.php file and add the jQuery library.

Here'south how:

  1. Start, go to Google Hosted Libraries and copy the latest version of the jQuery library in its entirety.
  2. Open up your header.php file, constitute in your themes binder.
  3. Add in the jQuery library from step one. Make sure it goes in right after the head tag.
  4. Save the file when you're washed.
Make sure this is what the snippet looks like in your wp-config.php file
What the snippet will look like in your wp-config.php file.

Adept news- you've institute the "jQuery is not defined" error. 🙃 Now it's time to solve information technology! ⬇️ Click to Tweet

Summary

And there y'all have it! Afterward following these steps, you lot should be able to resolve the "jQuery is non defined" error and admission your site.

Since this trouble is typically due to the browser's inability to connect with your jQuery library, there are a express number of solutions y'all tin can endeavour. Most people discover success with whatever of the above options.

If none of the above steps have resolved the mistake for some reason, information technology'south a practiced idea to contact your hosting company for support.

Take you encountered this error before? How did you solve it? Let us know in the comments section!


Save time, costs and maximize site operation with:

  • Instant help from WordPress hosting experts, 24/seven.
  • Cloudflare Enterprise integration.
  • Global audience accomplish with 32 data centers worldwide.
  • Optimization with our built-in Application Performance Monitoring.

All of that and much more, in one programme with no long-term contracts, assisted migrations, and a 30-day-coin-back-guarantee. Cheque out our plans or talk to sales to discover the plan that's correct for yous.