◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Hosting → jQuery
WordPress jQuery not defined and how to fix it
The “jQuery is not defined” error in WordPress usually means your site is trying to use jQuery before it has been properly loaded. It’s a common JavaScript error, especially after theme or plugin updates, and can break features like sliders, forms, or dropdown menus.
The good news? It’s fixable once you understand why it’s happening.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
What causes the “jQuery is not defined” error?
This error means that your browser is trying to run a script that uses jQuery, but jQuery hasn’t been loaded yet, or it wasn’t loaded correctly. Here are the most common causes:
- jQuery is not enqueued properly in WordPress
- jQuery is being loaded in the wrong order
- You’re using jQuery in the wrong scope (i.e., $ is not recognized)
- A plugin or theme deregistered jQuery
- CDN or external jQuery link failed to load
How to check if jQuery is loading correctly
Before diving into solutions, make sure jQuery is being loaded on your page:
- Open your site in Chrome.
- Right-click and choose Inspect to open Developer Tools.
- Go to the Console tab.
- Look for an error like: Uncaught ReferenceError: jQuery is not defined
- Check the Network tab and search for jquery.js to see if it loaded.
If it’s missing, failed, or loaded after your script, you’ll need to fix how it’s enqueued.
How to fix jQuery is not defined in WordPress
1. Enqueue jQuery properly in functions.php
WordPress comes with jQuery built-in, but you still have to enqueue it properly:
function my_custom_scripts() {
wp_enqueue_script(‘jquery’);
wp_enqueue_script(‘my-custom-script’, get_template_directory_uri() . ‘/js/my-script.js’, array(‘jquery’), null, true);
}
add_action(‘wp_enqueue_scripts’, ‘my_custom_scripts’);
Key points:
- Always list ‘jquery’ as a dependency.
- The last argument true ensures the script loads in the footer.
2. Don’t load jQuery from an external source unless necessary
Some themes or developers try to load jQuery from a CDN like Google:
wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js’);
wp_enqueue_script(‘jquery’);
This can break your site if:
- The CDN is blocked or slow
- It’s loaded after other scripts
- It conflicts with WordPress scripts
Unless you have a good reason, stick with the default WordPress jQuery.
3. Use jQuery instead of $ in your custom scripts
In WordPress, $ is not always available because jQuery is loaded in no-conflict mode.
Instead of this:
$(document).ready(function() {
// your code
});
Use this:
jQuery(document).ready(function($) {
// $ now refers to jQuery safely
});
This wrapper makes sure your code works with WordPress without breaking other libraries.
4. Check for plugin or theme conflicts
Sometimes plugins or themes:
- Deregister jQuery by mistake
- Load jQuery in the wrong order
- Override default WordPress behavior
To test this:
- Temporarily switch to a default theme like Twenty Twenty-Four
- Disable all plugins
- Re-enable them one at a time to find the culprit
Once you identify the source, check if there’s an update or contact the developer.
5. Use the right action hook to enqueue scripts
If you enqueue scripts too early (like in init), jQuery might not load in time.
Use the wp_enqueue_scripts action:
add_action(‘wp_enqueue_scripts’, ‘my_custom_scripts’);
This hook ensures scripts are enqueued when WordPress is ready.
6. Defer or async attributes might break jQuery
If you’re using a performance plugin or manually adding async or defer to script tags, it can cause jQuery to load after your scripts that depend on it.
To fix this, exclude jquery.js from deferring or async execution in your performance settings.
7. Check for errors in minified or combined scripts
Minification tools like Autoptimize or LiteSpeed Cache can sometimes break script order.
Try disabling minification temporarily and clear your cache. If the error goes away:
- Adjust the plugin settings to exclude jQuery or control script order
- Clear all cache (site, browser, CDN)
jQuery CDN best practices (if you do need to use one)
If you decide to load jQuery from a CDN, follow these best practices:
- Load it from a reliable CDN (like Google or jsDelivr)
- Add a fallback in case the CDN fails:
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js“></script>
<script>window.jQuery || document.write(‘<script src=”/wp-includes/js/jquery/jquery.js”><\/script>’);</script>
- Load it before other scripts that depend on it
- Only deregister WordPress’s jQuery if absolutely necessary
How to prevent the jQuery error in the future
- Always enqueue scripts the WordPress way
- Avoid hardcoding <script> tags in your header or footer
- Use jQuery(document).ready() for safe execution
- Regularly update your theme, plugins, and WordPress core
- Test after every major update
Use browser developer tools and tools like Query Monitor to catch script errors early.
Next steps to fix the jQuery Not Defined error
The most common reason for this error is that jQuery isn’t enqueued properly or is being called before it’s loaded. If you’re seeing the “jQuery is not defined” message, start by checking your theme or plugin code to ensure jQuery is enqueued using wp_enqueue_script() with ‘jquery’ listed as a dependency.
That one change is often enough to get your scripts working again and restore broken functionality on your site.
Ready to streamline your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy. Liquid Web’s WordPress hosting options configure business-class servers and support plans specifically for WordPress websites.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
Diagnosing WordPress errors on your site →
Even more common errors, how to troubleshoot them, and how to solve them
WordPress Multisite cookie error (and how to fix it) →
Fix the WordPress multisite cookie error by updating your domain settings and clearing browser cookies.
What is managed WordPress hosting? →
What it means, what it includes, and how to decide if it’s right for you