Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The WordPress “Uncaught ReferenceError: jQuery is not defined” error means a script tried to use the global jQuery name before it was available in that page’s execution context. It does not prove that WordPress has no jQuery anywhere on the site. The usual fixes are to restore the script’s registered dependency, correct a failed or missing jQuery request, or undo an optimization or theme/plugin conflict that changed script loading order.

What the error means

A browser reports this error when JavaScript refers to jQuery but that name is not available when the code runs. The cause may be a missing or failed jQuery load, or dependent code running too early. A theme or plugin conflict can also affect the page’s scripts. The message identifies a timing or availability problem, not the component that caused it.

If the message instead says $ is not defined, jQuery may still be loaded: WordPress runs jQuery in noConflict mode, so the shorthand $ is not necessarily a global alias.

Diagnose the failing page before changing code

  1. Reproduce the issue while logged out. Open the affected page in a private browser window. If the error appears only for logged-out visitors, compare that page’s output and requests with the logged-in view.
  2. Use the browser’s Console and Network panels. In the Console, identify the first script that throws the ReferenceError. In Network, check whether the jQuery script was requested, whether it completed successfully, and whether the browser reported an error.
  3. Compare script order. If you can, compare the rendered script tags on a failing page and a working one. Check whether jQuery appears before the script that depends on it.
  4. Change one condition at a time. Compare the page with optimization enabled and temporarily bypassed, then use controlled theme and plugin tests. A single change per test helps distinguish a failed request from an ordering or compatibility problem.

Fix a missing or incorrectly registered dependency

For a theme or plugin script that needs jQuery, use WordPress’s script-enqueue system and declare jquery as a dependency. WordPress documents the front-end wp_enqueue_script() function and its dependency argument; when the dependency handle is registered, WordPress places it before the dependent script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_script(
        'theme-custom',
        get_stylesheet_directory_uri() . '/js/custom.js',
        array( 'jquery' ),
        '1.0.0',
        true
    );
} );

This is an illustrative pattern: use the correct file path and handle for your site. If the code belongs to a plugin, correct that plugin’s registration or ask its author for a dependency-aware fix. Avoid pasting in a hard-coded jQuery URL or adding a second copy as the first response; duplicate libraries can introduce new conflicts rather than fix the dependency.

Fix code that uses $ instead of jQuery

WordPress’s jQuery runs in noConflict mode. The official wp_enqueue_script() reference warns that the common $ alias cannot be assumed globally. In custom code, pass jQuery into a function and use $ only inside that function:

Rank #2
Sale
JavaScript and jQuery: Interactive Front-End Web Development
  • JavaScript Jquery
  • Introduces core programming concepts in JavaScript and jQuery
  • Uses clear descriptions, inspiring examples, and easy-to-follow diagrams
( function( $ ) {
    // Use $ for jQuery inside this function.
} )( jQuery );

This addresses the $ is not defined case when jQuery is present. It does not fix a missing or failed jQuery request; use the Network panel to distinguish those situations.

Check whether optimization changed script order

Temporarily disable the relevant JavaScript combine, defer, or delay option and retest the affected feature. If the error disappears, re-enable optimization and use a narrow exclusion or corrected dependency rather than leaving all JavaScript optimization off.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For WP Rocket specifically, its troubleshooting guide for “jQuery is not defined” describes exclusions for its combine, defer, and delay features. Those controls are product-specific; for another optimization plugin, use its own settings and inspect the page’s rendered scripts after each change.

The loading strategies matter: WordPress’s script reference distinguishes defer, which runs after the document is parsed while retaining order among deferred scripts, from async, whose execution order is not guaranteed. Since WordPress 6.3, its registered and enqueued loading strategy considers the dependency tree when applying an eligible strategy. That makes declaring dependencies important, but it cannot ensure that every third-party optimizer or custom script-tag filter preserves the final output order.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Isolate a theme or plugin conflict

If jQuery loads successfully and the dependency is registered, test for a conflict. WordPress support recommends checking with a default theme in relevant troubleshooting cases; its support forums also illustrate why an individual theme or plugin report is a clue, not proof of a universal cause.

  1. Temporarily switch to a default WordPress theme and check the same page and feature.
  2. If the error remains, disable plugins as appropriate for your site and test again.
  3. Restore the original theme or re-enable plugins one at a time, retesting after each change until the error returns.

When the error returns after a specific change, inspect that component’s scripts and settings. If the site is business-critical, perform disruptive tests on a staging copy where possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 1
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 2
JavaScript and jQuery: Interactive Front-End Web Development
JavaScript and jQuery: Interactive Front-End Web Development
JavaScript Jquery; Introduces core programming concepts in JavaScript and jQuery; Uses clear descriptions, inspiring examples, and easy-to-follow diagrams
$24.04

Confirm the repair

  • Clear the relevant page, browser, CDN, or optimization caches after changing script settings.
  • Retest the exact affected page and feature in a logged-out session.
  • Check Console and Network again to confirm the ReferenceError is gone and jQuery loads before its dependent code.
  • If you used an optimization exclusion, keep it as narrow as practical and verify that the feature still works with the rest of the site’s optimization settings enabled.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.