WordPress

WordPress Reference Error is not defined : Fix jQuery is not defined

jQuery is not defined is one of the most common JavaScript errors and it can make things stop working on your WordPress website. Here how it does look like in your browser console.

WordPress Reference Error is not defined : Fix jQuery is not defined

WordPress Reference Error is not defined : How to Fix

Common Causes:

  1. One of yours plugins’ JavaScript files are not properly loaded.
  2. Some JavaScript is running before the page is fully loaded, and as such, before jQuery is fully loaded.
  3. Your CDN-hosted jQuery might be blocked or down.

How to Fix?

Sometimes it will be too complicated to find the root of the issue, as you may not be able to find the culprit plugin, theme or the function that causes that issue. jQuery is not defined issue also could happen due to incompatibility between plugins and themes, snap! In such cases, it’ll be such a pain in the..!

Method 1

Add this line to your wp-config.php file:

Method 2

If method 1 (which is recommended) does not work, the other way to fix this issue is by adding the jQuery library directly to your theme header.php file by following these steps:

  1. Get the latest version of jQuery Library from Google Hosted Libraries
  1. Open your theme’s header.php file
  2. Paste what you got in the first step just after the head tag.
  3. Save your file.

Conclusion:

What we discussed here is not the optimal solution for fixing jQuery is not defined issue. As we mentioned, it can be too complicated to find the exact cause of the problem, so you can consider this as a quick workaround.

Leave a Comment