Nothing on the page says “error”. The slider just sits on its first image. The mobile menu button does nothing. The “Add to cart” button refreshes the page instead of updating the cart, or a form will not submit. Someone suggests opening the browser console, and there, in red, is a line that reads “Uncaught ReferenceError: jQuery is not defined”.
A “jQuery is not defined” error on a WordPress site looks alarming, but the message is precise. It means a piece of JavaScript tried to use jQuery before jQuery was available, or on a page where it was never loaded. The job is to find out which script asked too early and why. This guide shows how to read the console, what the related messages mean, and the handful of causes behind nearly all of them.
Opening the console without breaking anything
Looking at the console is completely safe; it only shows information.
- Open the broken page in Chrome, Edge or Firefox on a computer. Use a private window so you see what visitors see.
- Press F12, or right-click anywhere and choose Inspect.
- Click the Console tab. Reload the page with the console open so you catch errors that happen during loading.
- Look for red lines. Each one shows a message and, on the right, the file and line number where it happened.
Click the file name on the right of an error. The browser opens the file and highlights the line. You do not need to understand the code. The file’s address tells you who wrote it: a path containing wp-content/plugins/ followed by a folder name points at that plugin; wp-content/themes/ points at the theme; a script written directly into the page, shown as the page address itself, usually came from a plugin or theme setting where someone pasted code.
It is worth knowing that WordPress’s PHP debug tools do not show these errors. JavaScript runs in the visitor’s browser, not on the server, so turning on WP_DEBUG and the PHP debug log will not record them. JavaScript errors in the console and PHP errors in the server log are two separate records, and you need the right one for the problem in front of you.
What each jQuery message is telling you
Several messages are closely related. Reading which one you have narrows the cause.
“jQuery is not defined”
At the moment the script ran, there was no jQuery on the page at all. Either it had not loaded yet, it failed to load, or nothing asked WordPress to load it.
“$ is not defined” or “$ is not a function”
jQuery may well be loaded, but the code is using the $ shortcut. WordPress loads its copy of jQuery in what is called no-conflict mode, which means the $ shortcut is not set up globally. Code written for ordinary websites often assumes $ means jQuery; on WordPress it does not, unless the code wraps itself in a way that passes jQuery in as $. This is very common with snippets copied from tutorials and pasted into a header or footer code box.
“jQuery(…).something is not a function”
Here jQuery exists, but a jQuery add-on, such as a slider or lightbox library, is missing. The add-on failed to load, loaded before jQuery, or was wiped out because a second copy of jQuery loaded after it. When jQuery loads twice, the second copy replaces the first and every add-on attached to the first copy disappears.
The same message can also mean old code is using a jQuery method that newer versions of jQuery no longer have. WordPress has updated its bundled jQuery over the years, and very old themes and plugins written against older jQuery behaviour can break this way after an update.
The four causes, most likely first
1. An optimisation plugin changed the loading order
Performance plugins and some hosting tools offer options like “defer JavaScript”, “delay JavaScript execution”, “combine JS” or “move scripts to footer”. They make pages appear faster by changing when and in what order scripts run. If jQuery is deferred or delayed but a script that needs it, often a small piece of code written directly into the page, is not, the script runs first and fails.
It is also the easiest cause to test. Turn off the JavaScript options in your optimisation plugin one at a time, clear every cache, and reload the page with the console open. When the red error disappears, you have found the setting. The usual long-term fix is to keep the option on and add jQuery, or the script that depends on it, to the plugin’s exclusion list, so the faster loading stays for everything else.
2. Code pasted into the site without saying it needs jQuery
WordPress has a proper way for themes and plugins to add scripts: they register them and declare which other scripts they depend on. WordPress then loads jQuery first, automatically, whenever something lists it as a dependency.
Code pasted straight into a header box, a footer box, a Custom HTML block or a theme template skips all of that. WordPress has no idea it needs jQuery. On many sites jQuery happens to be loaded anyway, because some plugin needs it. But WordPress does not load jQuery on the front end unless something asks for it, so on a lean site, or after you remove the plugin that used to ask for it, the pasted code suddenly fails.
If the error points at the page address rather than a plugin or theme file, look for pasted code in theme options, header and footer script plugins, and Custom HTML blocks. A developer can register it properly, or wrap it so it waits for jQuery and uses it safely.
3. jQuery itself failed to load, or loaded twice
Open the browser’s Network tab, reload the page, and type “jquery” in the filter box. You should see WordPress’s own file, which lives under /wp-includes/js/jquery/. Look for:
- A red or failed entry. The file did not load. A security rule, a CDN fault or a broken optimisation cache can cause this.
- No WordPress copy, only an outside one. Some themes swap WordPress’s jQuery for a copy from a public CDN. If that outside copy is blocked or slow, the site loses jQuery.
- Two different copies. A theme or plugin is adding its own jQuery on top of WordPress’s. That causes the “is not a function” errors described above. The extra copy should be removed so everything uses the one WordPress provides.
4. An update changed something
If the error started on a specific day, line it up against updates. A plugin update may have started loading its scripts differently, a theme update may have dropped jQuery because the theme no longer needs it, or a WordPress update may have refreshed the bundled jQuery. Rolling back one suspect at a time on a staging copy is the clean way to confirm it. For a broader look at failures that start right after updates, see our page on a site that broke after an update.
Why one error can break so many things
When a script stops on an error, the rest of that script does not run. If a theme bundles its menu, slider, accordion and sticky header into one file, a single jQuery error at the top of that file takes all of them out together. That is why the symptoms often look unrelated: the menu, the gallery and a form all fail at once.
It also means fixing the first red error in the console often clears several others. Always start with the earliest error on the list, then reload and see what remains. The guides on a slider that will not move and buttons that do nothing when clicked go into those specific symptoms once the JavaScript side is clean.
What to copy for a developer
If you need to pass this on, a screenshot of the console with the first red error expanded is the most useful single thing you can send. Add:
- The page address and the browser you used
- The file name and line number shown beside the error
- Which optimisation plugin you use and which JavaScript options are on
- Any code you or someone else pasted into the site’s header, footer or blocks
- When the problem started, and what was updated around then
Mozilla’s reference on the “is not defined” ReferenceError explains the general JavaScript error, if you want the background.
When to stop and pass it on
Stop when the error points into a plugin or theme file you would have to edit, when switching off optimisation settings does not change anything, or when the site sells online and the broken button is in the checkout. Those are the cases where guessing costs money. If you want the jQuery error and its knock-on faults traced and fixed properly, our page on getting wordpress bugs fixed explains how a single job works and costs.
Whatever you do, read the first red line before changing anything. It names the file, and the file usually names the culprit.
Next in this series: WordPress Slider Not Working? Find the Cause by Symptom