How to Fix WordPress ‘jQuery is not defined’ Error (6 Ways)

Should you’re seeing the ‘jQuery is just not outlined’ error in your WP admin space (or elsewhere), don’t fear – you’re not alone. It is a widespread subject that many WP customers encounter. That mentioned, it may be irritating when your web site doesn’t work as anticipated.

We’ve been working with WP for effectively over a decade, and through that point, we’ve discovered the best way to troubleshoot and resolve among the most typical WP errors. That features the ‘jQuery is just not outlined’ error.

On this information, we’ll talk about why this error happens and, extra importantly, the best way to repair it. We’ll clarify every little thing in easy phrases, so even should you’re not a developer, you’ll be capable of observe alongside and resolve the issue rapidly.

Fixing jQuery not defined  error in WordPressFixing jQuery not defined  error in WordPress
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 1

What Causes the ‘jQuery is just not outlined’ Error?

jQuery is a extensively used JavaScript library in WP that helps run many interactive options. Nonetheless, generally, it might fail to load appropriately, which might have an effect on the performance of your web site.

The error seems within the developer instruments below the Console tab, so many customers could not discover it till one thing breaks on their web site.

JQuery not defined error in the consoleJQuery not defined error in the console
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 2

Should you see the ‘jQuery is just not outlined’ error, it means WP is having hassle loading it correctly. Through the years, we’ve helped numerous customers repair this subject, and we’ve discovered that it normally stems from just a few widespread causes:

  1. Outdated Themes or Plugins: Many customers encounter this error when their themes or plugins aren’t up to date to match the most recent model of WP. We’ve usually seen this occur after main WP updates.
  2. Improper Script Loading: jQuery should be loaded earlier than different JavaScript information. If it’s not, scripts that rely on jQuery will break. This usually happens if themes or plugins aren’t coded appropriately to enqueue scripts​.
  3. JavaScript Conflicts: Different scripts working in your web site could battle with jQuery, particularly in the event that they’re not correctly loaded. This battle can break jQuery, inflicting the error.
  4. CDN Failures: Some websites depend on jQuery hosted on a Text Supply Community (CDN). If the CDN is unavailable or blocked, the location received’t be capable of load jQuery, ensuing within the error.​

All of those points can forestall jQuery from working easily. However don’t fear – with our expertise, we will information you thru the options to resolve the issue.

Repair the ‘jQuery is just not outlined’ Error

There are a number of methods to repair this error while you encounter it. Beneath are the best strategies we’ve used to repair this drawback.

We suggest making an attempt out these methods so as, however you need to use the soar hyperlinks under should you’d like to start out with a selected one:

We’ll go over every of those strategies after which give you some further assets for troubleshooting WP errors. Let’s get to it!

1. Replace WP, Themes, and Plugins

Outdated software program is without doubt one of the most typical causes of the ‘jQuery is just not outlined’ error. Outdated themes or plugins will not be suitable with the most recent model of WP, which may end up in script conflicts. To repair this:

READ  White Labeling Ecommerce Explained for Beginners

First, make sure that your WP core is up to date. Navigate to Dashboard » Updates and click on ‘Replace to model X.X.X’ if an replace is offered.

Update WordPress coreUpdate WordPress core
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 3

See our full information on safely updating WP to a brand new model for extra particulars.

Your WP plugin updates can be listed under the core replace.

You possibly can choose all of them and click on ‘Replace Plugins.’

Installing WordPress updatesInstalling WordPress updates
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 4

Lastly, you will note updates on your WP themes.

Merely choose all of them and click on ‘Replace Themes.’

Update WordPress themesUpdate WordPress themes
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 5

In case you are involved in regards to the adjustments you’ve got made to your theme, observe our information on the best way to replace your WP theme with out dropping customizations.

2. Examine If jQuery Is Loaded Correctly

Earlier than exploring extra superior options, it’s vital to examine whether or not jQuery is definitely being loaded in your web site. This step helps you verify whether or not the jQuery is offered and functioning because it ought to.

Merely right-click anyplace in your WP web site and choose ‘View Section Supply.’

Tip: Alternatively, you may press Ctrl + U on Home windows or Cmd + Possibility + U on Mac to entry the web page supply.

It will present you the uncooked HTML and JavaScript on your web page.

View page sourceView page source
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 6

Subsequent, press Ctrl +F (or Cmd + F on Mac) to carry up the search bar, and kind ‘jquery.min.js.’

If jQuery is loaded appropriately, it’s best to see a reference to it within the code.

Search jQuery in source codeSearch jQuery in source code
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 7

One other method to search for jQuery is to make use of your browser’s Examine Device. Merely go to the ‘Community’ tab and reload the web page.

Tip: On a Home windows gadget, you may entry the Examine Device by urgent F12 in your keyboard. For Mac, hit Choices + Cmd + I.

Filter the community exercise by typing ‘jquery’ within the search bar. If jQuery is loaded, you’ll see it listed right here.

Look for jQuery in Developer ToolsLook for jQuery in Developer Tools
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 8

Should you don’t see jQuery loaded in both technique, the problem could also be the way it’s enqueued in WP. Within the following steps, we’ll information you thru fixing this.

3. Add a jQuery Fallback

Generally, a script in your web site could also be loading jQuery utilizing a CDN that’s having connectivity points. In that case, it will fail to load jQuery and trigger the error.

To repair the issue, you may add a jQuery fallback to your WP web site. This ensures that jQuery is at all times loaded.

You must add it to your web site’s head part to make sure it hundreds first. Nonetheless, we don’t suggest enhancing theme information instantly. We now have seen folks lose their adjustments when updating the theme and the code they added.

The easiest way so as to add customized code in WP is to make use of the WPCode plugin. It’s a code snippet supervisor that allows you to add customized code safely with out breaking your web site.

READ  How to Fix WordPress Nav Menu Appearing Under Admin Bar

First, set up and activate the WPCode plugin. For particulars, see our tutorial on putting in a WP plugin.

Word: There may be additionally a free model accessible referred to as WPCode Lite.

As soon as activated, go to Code Snippets » + Add Snippet. Then, click on on the ‘Use snippet’ button below ‘Add Your Unique Code (New Snippet).’

wp wpcode addnew snippet 1wp wpcode addnew snippet 1
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 9

Within the code editor, give your snippet a reputation like ‘jQuery Fallback.’

After that, choose ‘HTML Snippet’ for the ‘Code Kind.’

Add your custom codeAdd your custom code
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 10

Subsequent, paste the next code within the ‘Code Preview’ field:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
    window.jQuery || doc.write('<script src="/wp-includes/js/jquery/jquery.js"></script>')
</script>

Then, scroll all the way down to the ‘Insertion’ part.

Right here, you may inform WPCode the place to load this code. Just be sure you choose ‘Website Broad Header.’

Load code site wide headerLoad code site wide header
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 11

Lastly, click on the ‘Save Snippet’ button on the prime to avoid wasting your customized code.

After that, don’t neglect to activate the snippet by switching the toggle to ‘Energetic.’

Save snippetSave snippet
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 12

4. Repair Script Loading Order (Superior)

One other widespread purpose for the ‘jQuery is just not outlined’ error is that jQuery is loading after different scripts that depend on it. Fixing the script loading order ensures that jQuery is at all times loaded first, stopping conflicts.

If which script depends on jQuery, you may enqueue that script correctly by including jQuery as a dependency.

If the ‘jQuery is just not outlined’ error is brought on by jQuery loading after different scripts that rely on it, you may repair the script loading order utilizing WPCode.

First, set up and activate the WPCode plugin, or go for the free model referred to as WPCode Lite.

As soon as activated, go to Code Snippets » + Add Snippet and click on on the ‘Use snippet’ button below ‘Add Your Unique Code (New Snippet).’

wp wpcode addnew snippet 1wp wpcode addnew snippet 1
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 13

Within the code editor, give your snippet a reputation like ‘Repair Script Loading Order’ and choose ‘PHP snippet’ as your code sort.

Then, add the next code to make sure jQuery is enqueued as a dependency for any customized scripts:

wp_enqueue_script( 'your-script-handle', get_template_directory_uri() . '/js/your-script.js', array( 'jquery' ), null, true );

Don’t neglect to exchange ‘your-script-handle’ with a significant identify to establish the script. And substitute the ‘/js/your-script.js’ with the precise script file identify in your theme’s /js/ folder.

The array('jquery') half within the code ensures that jQuery is loaded first.

After getting added the code, scroll all the way down to the ‘Insertion’ choices and choose ‘Website Broad Header’ to verify the script is loaded in the correct a part of your web site’s HTML.

Load code site wide headerLoad code site wide header
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 14

Lastly, click on the ‘Save Snippet’ button on the prime to avoid wasting your customized code.

After that, don’t neglect to activate the snippet by switching the toggle to ‘Energetic.’

Save snippetSave snippet
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 15

Utilizing WPCode to correctly enqueue scripts ensures jQuery is loaded within the right order. If that was the problem’s root, this could resolve the error.

5. Edit wp-config.php to Repair jQuery Loading Points

If the opposite strategies haven’t labored, enhancing the wp-config.php file may also help by controlling how WP handles script loading.

READ  How to Show Upcoming Events in WordPress (The Easy Way)

This technique is useful if script concatenation or file path points are inflicting the ‘jQuery is just not outlined’ error.

Right here’s the best way to apply this technique:

First, entry your wp-config.php file. You are able to do this utilizing an FTP shopper like FileZilla or by accessing the file supervisor in your internet hosting management panel.

The wp-config.php file is positioned within the root listing of your WP set up (normally within the public_html folder).

When you’ve positioned the file, open it for enhancing and add the next code simply earlier than the road that claims /* That’s all, cease enhancing! Joyful running a blog. */:

/** Absolute path to the WP listing. */
if ( !outlined('ABSPATH') )
outline('ABSPATH', dirname(FILE) . '/');
outline('CONCATENATE_SCRIPTS', false);

Right here’s what this code does:

  • The ABSPATH definition ensures that WP is aware of the right path to its core information, which might forestall jQuery loading points.
  • The CONCATENATE_SCRIPTS line disables script concatenation. This forces WP to load every script individually, stopping conflicts that come up when scripts are merged.

After including this code, save your adjustments and reload your web site to see if the error has been resolved.

Disabling script concatenation could be a easy however efficient repair for jQuery points, particularly when different strategies don’t work.

6. Get Premium Assist to Repair the Error for You

If not one of the above strategies work otherwise you would merely quite have an knowledgeable check out your subject, then it’s best to think about using our Premium WP Assist companies.

Emergency WordPress SupportEmergency WordPress Support
How to Fix WordPress 'jQuery is not defined' Error (6 Ways) 16

For a small one-time charge, you may rent our extremely expert, skilled WP engineers to repair the error for you.

Once you select our emergency companies, you received’t need to cope with the trouble of making an attempt to repair the ‘jQuery is just not outlined’ error by yourself.

This manner, your web site will expertise minimal downtime, and you may resume your on-line enterprise operations as quickly as doable.

Plus, our emergency companies received’t lock you right into a contract, so it may be an awesome possibility should you aren’t all in favour of a full-blown upkeep assist plan.

That mentioned, we do supply extra complete Upkeep Companies if you wish to take a extra proactive method and cut back the danger of web site emergencies sooner or later.

Bonus Sources: Troubleshooting WP Errors

If all of the above steps don’t assist otherwise you want to learn additional, then the next assets may very well be good beginning factors:

We hope this text helped you repair the ‘jQuery is just not outlined’ error in WP. You may additionally wish to see our information on upgrading jQuery to the most recent model in WP or our choose of the perfect jQuery tutorials for WP novices.

Should you appreciated this text, then please subscribe to our YouTube Channel for WP video tutorials. You may as well discover us on Twitter and Fb.

Leave a Reply

Your email address will not be published. Required fields are marked *