The “jQuery $ is not defined” error is one of the most common JavaScript errors that web developers encounter. This comprehensive guide will walk you through everything you need to know to identify, troubleshoot, and permanently fix this frustrating issue.
What Does “jQuery $ is not defined” Mean?
The “jQuery $ is not defined” error occurs when your JavaScript code tries to use jQuery functions (like $() or jQuery()) before the jQuery library has been properly loaded or when jQuery isn’t available at all. This error typically appears in your browser’s developer console and can break your website’s interactive functionality.
Common Causes of the jQuery Error
Let me showcase some common causes of the jQuery error.
1. jQuery Library Not Loaded
The most frequent cause is simply forgetting to include the jQuery library in your HTML document. Without loading jQuery first, the browser doesn’t recognize the $ symbol or jQuery functions.
2. Incorrect Loading Order
Even if jQuery is included, loading your custom JavaScript before the jQuery library will trigger this error. Scripts must be loaded in the correct sequence.
3. CDN Issues
When using Content Delivery Networks (CDNs) to load jQuery, network issues, blocked CDNs, or server downtime can prevent the library from loading properly.
4. Capitalization Errors
JavaScript is case-sensitive. Writing jquery instead of jQuery or using incorrect syntax can cause this error.
5 Proven Methods to Fix “jQuery $ is not defined”
Let me explain to you some methods to fix the “jQuery $ is not defined” error.
Method 1: Verify jQuery is Properly Loaded
First, ensure you’ve included the jQuery library in your HTML head section:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<!-- Your content here -->
<script>
$(document).ready(function() {
console.log("jQuery is working!");
});
</script>
</body>
</html>I executed the above example code and added the screenshot below.

Method 2: Check Script Loading Order
Always load jQuery before any scripts that use it:
<!-- CORRECT ORDER -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="your-custom-script.js"></script>
<!-- INCORRECT ORDER - Will cause errors -->
<script src="your-custom-script.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>Method 3: Use Browser Developer Tools for Debugging
Use the Network tab in your browser’s developer tools to verify jQuery is loading successfully:
- Open Developer Tools (F12)
- Go to the Network tab
- Reload your page
- Look for the jQuery file – it should show a 200 status code
- If you see 404 or other error codes, the jQuery file isn’t loading properly
Method 4: Implement Local Fallback for CDN
Create a backup plan in case CDN-hosted jQuery fails:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
if (typeof jQuery == 'undefined') {
document.write('<script src="js/jquery-3.6.0.min.js"><\/script>');
}
</script>I executed the above example code and added the screenshot below.

Method 5: Use jQuery.noConflict() for Compatibility
If you’re working with multiple libraries that use the $ symbol:
jQuery.noConflict();
jQuery(document).ready(function($) {
// Use $ freely within this function
$("#myElement").hide();
});
// Or assign jQuery to a different variable
var $j = jQuery.noConflict();
$j("#myElement").show();WordPress-Specific Solutions
WordPress users often encounter this error due to theme or plugin conflicts. Here’s how to fix it:
// In your theme's functions.php file
function properly_enqueue_jquery() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'properly_enqueue_jquery');For WordPress themes, always use wp_enqueue_script() instead of manually including jQuery in your header.
Advanced Troubleshooting Techniques
Check for Conflicting Scripts
Some scripts may interfere with jQuery loading. Temporarily disable other JavaScript files to isolate the issue:
// Add this at the top of your script to check if jQuery is available
if (typeof $ === 'undefined') {
console.error('jQuery is not loaded!');
} else {
console.log('jQuery version: ' + $.fn.jquery);
}Async Loading Considerations
When loading scripts asynchronously, ensure jQuery is fully loaded before executing dependent code:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
onload="jQueryLoaded()" onerror="jQueryError()"></script>
<script>
function jQueryLoaded() {
console.log('jQuery loaded successfully');
// Your jQuery code here
}
function jQueryError() {
console.error('Failed to load jQuery');
// Load fallback or show error message
}
</script>Best Practices to Prevent Future Errors
- Always load jQuery first before any dependent scripts
- Use reliable CDNs like Google CDN or jQuery’s official CDN
- Implement fallback mechanisms for CDN failures
- Test across different browsers and devices
- Use browser developer tools regularly to monitor script loading
- Keep jQuery updated to the latest stable version
Testing Your Fix
After implementing any solution, verify it works by:
- Opening your browser’s console
- Refreshing the page
- Checking for any remaining JavaScript errors
- Testing jQuery functionality on your website
The “jQuery $ is not defined” error, while common, is easily fixable with the right approach. By following this guide and implementing proper loading practices, you can ensure your jQuery code runs smoothly and your website functions as intended.
Remember to always test your changes thoroughly and consider implementing fallback solutions for mission-critical websites. With these techniques in your toolkit, you’ll be able to quickly resolve jQuery loading issues and maintain robust web applications.
You may also like to read:
- jQuery Wait for Function to Finish
- jQuery Open Link in New Tab
- jQuery Set Focus on Element
- How to Get the Value of a Textarea in jQuery

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.