If you've ever pasted a jQuery snippet into a WordPress theme and watched it do absolutely nothing, you've met WordPress's noConflict mode. It's one of the most common sources of confusion for developers moving from standalone jQuery projects into WordPress. The code is correct. The syntax is fine. But the $ shortcut doesn't exist, and your browser console is quietly logging a ReferenceError: $ is not defined.
WordPress has bundled jQuery since version 2.0, way back in 2010. It powers the admin interface, the classic editor, and countless themes and plugins. But it's loaded in noConflict mode to avoid collisions with other JavaScript libraries that WordPress or its plugins might load. That single decision shapes how every line of jQuery you write in a WordPress context needs to be structured.
This guide covers the correct patterns for jQuery document ready in WordPress, how to enqueue scripts properly, the mistakes that cause the most headaches, and what the jQuery 4.0 release means for the WordPress ecosystem in 2026. If you want the general jQuery document ready fundamentals first, our jQuery document ready beginner's guide covers the basics. This post is the WordPress-specific version.
Why WordPress Uses noConflict Mode
The jQuery library included with WordPress is set to noConflict() mode. This is a deliberate decision to prevent compatibility problems with other JavaScript libraries that WordPress can load—things like Prototype, MooTools, or YUI, which also use the $ variable.
In noConflict mode, the global $ shortcut for jQuery is not available. The full jQuery identifier still works, but the shorthand doesn't. That means this code fails:
$(document).ready(function () {
// This throws an error in WordPress
$(".selector").hide();
});
But this code works:
jQuery(document).ready(function () {
jQuery(".selector").hide();
});
If you want to use the $ shortcut—and most developers do, because it's shorter and more familiar—you pass $ as a parameter to the ready callback. Inside that callback, $ refers to jQuery. Outside, it's whatever else claimed the name.
jQuery(document).ready(function ($) {
// Inside this function, $ works as an alias for jQuery
$(".selector").hide();
});
This is the pattern you'll see in virtually every WordPress jQuery tutorial, and for good reason. It's the cleanest way to use the shorthand without causing conflicts. Our jQuery document ready vs vanilla JavaScript guide explains the broader comparison, but in WordPress, this wrapper is non-negotiable unless you're using the full jQuery identifier everywhere.
The Right Way to Enqueue jQuery in WordPress
WordPress has a queue system for scripts called wp_enqueue_script. You don't add <script> tags directly to your theme's header or footer. Instead, you register your script and declare jQuery as a dependency. WordPress handles the rest—loading jQuery first, then your script, in the correct order.
Here's the pattern for a theme's functions.php:
function my_theme_scripts() {
wp_enqueue_script(
'my-custom-script', // handle
get_template_directory_uri() . '/js/custom.js', // source
array( 'jquery' ), // dependencies
'1.0.0', // version
true // load in footer
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
The third parameter—array( 'jquery' )—is the critical piece. It tells WordPress that your script depends on jQuery, so WordPress will load jQuery before your script. If you omit this, your script might load before jQuery, and you'll get the dreaded "jQuery is not defined" error.
The fifth parameter, true, loads the script in the footer instead of the head. This is generally the right choice because it doesn't block page rendering. It also ensures the DOM is already parsed when your script runs, which reduces the need for a document ready wrapper. But it doesn't eliminate it—if your script is loaded in the head (for whatever reason), the wrapper is essential.
If you're enqueueing from a child theme, use get_stylesheet_directory_uri() instead of get_template_directory_uri(). If you're working in a plugin, use plugins_url().
Common Document Ready Mistakes in WordPress
Even developers who know about noConflict mode still run into problems. Here are the mistakes I see most often.
Mistake 1: Using $(document).ready() without the wrapper. This is the number one issue. If you've copied a snippet from a non-WordPress tutorial, it probably starts with $(document).ready(function() { ... }). In WordPress, that code never runs because $ is undefined. Always use jQuery(document).ready(function($) { ... }).
Mistake 2: Forgetting to enqueue jQuery as a dependency. Your code is correct, but your script loads before jQuery. The dependency array in wp_enqueue_script fixes this. If you're loading a script in a template file with a raw <script> tag—don't. Use wp_enqueue_script.
Mistake 3: Adding <script> tags directly to template files. WordPress has a script queue for a reason. Direct <script> tags bypass the dependency system, making it impossible to guarantee load order. They also clutter template files and make maintenance harder. Our JavaScript document ready guide covers the modern approaches, but in WordPress, the enqueue system is the only correct way.
Mistake 4: Loading jQuery from a CDN. This is tempting for performance reasons, but it's a bad idea in WordPress. The WordPress-bundled jQuery is version-managed, tested with core, and guaranteed to work with the plugins your site uses. Loading a different version from a CDN can break other plugins and cause subtle conflicts.
Mistake 5: Using $(window).load() or window.onload. These wait for all images and assets to load, which is slower than necessary. Use jQuery(document).ready() or DOMContentLoaded instead.
WordPress Admin Area: Different Context, Same Rules
The WordPress admin area uses jQuery heavily—the classic editor, meta boxes, admin menus, and many plugin settings pages rely on it. If you're writing custom scripts for the admin, the rules are the same, but the enqueue hook is different.
function my_admin_scripts() {
wp_enqueue_script(
'my-admin-script',
plugin_dir_url( __FILE__ ) . 'js/admin.js',
array( 'jquery' ),
'1.0.0',
true
);
}
add_action( 'admin_enqueue_scripts', 'my_admin_scripts' );
Use the admin_enqueue_scripts hook instead of wp_enqueue_scripts. The dependency on jQuery still matters, and the noConflict mode still applies. The same document ready wrapper is required.
For the block editor (Gutenberg), things are different. The block editor is built on React, not jQuery. Adding jQuery to the block editor is possible but discouraged—the editor's state management is handled through wp.data, and mixing jQuery into that model creates friction. If you're building a block, use React and the block editor APIs. Save jQuery for the classic editor and traditional admin pages.
jQuery 4.0 and WordPress: What's Changing
jQuery 4.0 was released in January 2026, and it brings breaking changes that affect WordPress. The biggest one: jQuery.trim() was removed entirely. It was deprecated since jQuery 3.3.0, and WordPress has been shipping jQuery Migrate to keep it working with a console warning. But jQuery 4.0 removes it completely.
Other removals include .bind() and .unbind() (replaced by .on() and .off()), .delegate() and .undelegate(), and .error() (the event method, not the error handling method). These were all deprecated in jQuery 3.x, and they're gone in 4.0.
WordPress core has been preparing for this. jQuery Migrate is slated for removal in WordPress 7.1, followed by a jQuery upgrade in 7.2. The timeline has been proposed but not yet locked in, and the effort has been languishing for years. But the direction is clear: jQuery 4.0 is coming to WordPress, and code that relies on removed methods will break.
If you're maintaining a theme or plugin with jQuery, now is the time to audit your code. Replace $.trim(value) with value.trim(). Replace .bind() with .on(). Replace .delegate() with .on(). The fixes are straightforward, but finding all the instances takes time.
Should You Still Use jQuery in WordPress in 2026?
This is the question every WordPress developer eventually asks. The honest answer: it depends.
jQuery still runs on roughly 77% of the top 10 million websites. WordPress themes and plugins rely on it extensively. The ecosystem isn't moving away from jQuery quickly, and if you're building a traditional WordPress theme or a plugin that needs to work with the existing plugin ecosystem, jQuery is often the path of least resistance.
But vanilla JavaScript is a viable alternative for many use cases. DOMContentLoaded replaces jQuery(document).ready(). querySelector and querySelectorAll replace $() and $('.selector'). classList replaces .addClass() and .removeClass(). fetch replaces $.ajax(). The native APIs are mature, well-supported, and don't require a 30 KB dependency.
The block editor has already shifted to React. The WordPress core team is slowly moving away from jQuery for new features. The long-term direction is clear, even if the timeline is measured in years rather than months.
My recommendation: if you're starting a new project and you don't need jQuery for plugin compatibility, consider vanilla JavaScript. If you're maintaining an existing project or building something that integrates deeply with the plugin ecosystem, jQuery is still a reasonable choice. Just be aware of the 4.0 breaking changes and audit your code accordingly.
For a deeper dive into the vanilla JavaScript alternatives, see our JavaScript document ready guide. And if you're optimizing WordPress performance, our guide on why modern websites feel slower covers how script loading and dependencies affect page speed.
A Real Story: Debugging a "Broken" jQuery Snippet
A few months ago, a client asked me to look at a WordPress site where a custom testimonial slider had stopped working. The site had been updated to WordPress 6.9, and the slider had been fine before.
I opened the browser console and saw the problem immediately: Uncaught ReferenceError: $ is not defined. The developer who built the slider had used $(document).ready() without the noConflict wrapper. It had worked for years because an older plugin had been loading the $ shortcut globally. That plugin was updated, dropped the shortcut, and the slider broke.
The fix was a single line: change $(document).ready(function() { to jQuery(document).ready(function($) {. That's it. One character added, one character removed, and the slider worked again.
The lesson: WordPress's noConflict mode isn't a bug to work around. It's a feature to write code against. Use the wrapper, declare your dependencies, and your jQuery will work consistently regardless of what other plugins are doing.
Wrapping Up
WordPress's noConflict mode is the source of most jQuery confusion in the ecosystem. The $ shortcut doesn't work globally. You have to use jQuery or wrap your code in jQuery(document).ready(function($) { ... }). You have to enqueue your scripts with wp_enqueue_script and declare jQuery as a dependency. And you have to be aware of the breaking changes coming in jQuery 4.0.
None of this is hard once you know it. But it's different from standalone jQuery development, and that difference trips up developers regularly. The patterns in this guide are the ones that work consistently across WordPress versions and configurations.
If you want the foundational jQuery document ready knowledge, start with our beginner's guide. For the vanilla JavaScript alternative, see our JavaScript document ready post. And if you're moving away from jQuery entirely, our jQuery vs vanilla JavaScript comparison covers the migration path.
Now go write some jQuery that actually works in WordPress.
Maintaining a WordPress site with custom jQuery or looking to modernize your theme's JavaScript? Red Surge Technology helps teams build WordPress experiences that perform. Get in touch to discuss your project.