Errors / JavaScript errors
Uncaught ReferenceError: $ is not defined (or jQuery is not defined)
A script needs jQuery and ran before jQuery was on the page, or jQuery never loaded.
Every jQuery feature on the page is dead: menus, sliders, pop-ups, form validation.
Why it happens
- jQuery is loaded after the script that uses it, or with
async/deferwhile the other script is not. - A performance plugin moved jQuery to the footer or delayed it, and inline scripts in the page still expect it at once.
- WordPress loads jQuery in no-conflict mode, where
$is not defined butjQueryis. - The jQuery file failed to load: a CDN blocked, a wrong path after a migration.
How to fix it
- Load jQuery first and without
async; on WordPress, enqueue your script withjqueryas a dependency. - In WordPress, write
jQuery(function ($) { … })so$exists inside. - If a speed plugin defers JavaScript, exclude jQuery and the scripts that need it inline.
- Check the jQuery request itself answered 200.
Whose problem it is
Usually the site's own code or settings.
Does your site have it?
Free, no account. We open your page and four more in a clean Chrome and list every error like this one, with the page and the click that caused it. How the free page check works.
Often seen with
- x is not definedA script used a name nobody declared, usually because another script it depends on did not load first.
- x is not a functionA script tried to use something as an action that is not one, and stopped.