How to Fix a ‘jQuery Not Defined’ Error for your WordPress

How to fix a ‘jQuery not defined’ error for your WordPress

WordPress is a great website creation platform and since it is a free, open-source program, it is very popular. So, chances are that you or someone you know is using WordPress to blog or share content. However, whether you are new to this CMS, or have been using it for a while, it is always a bit jarring to see the ‘WordPress jQuery is not defined’ alert.

Before we delve into a solution for this error, it is important to know what it is, what it does, and why a WordPress ‘jQuery is not defined’ warning pops up. Below are the answers to some of the most common questions regarding this error, and how to fix it.

What is the jQuery?

What is the jQueryjQuery is a cross-platform JavaScript library. It helps by making things like HTML document manipulation and traversal, Ajax, event handling, and animation easier. It works with easy-to-operate APIs, that run across different browsers. In simple words, it makes it easier for your chosen web pages to use JavaScript, making the experience better and more interactive.

What is a jQuery not Defined Error on WordPress?

WordPress, like all websites, uses JavaScript, and jQuery occurs when there is a conflict with the other libraries that JavaScript uses. The main reason that the WordPress jQuery is not defined, is because the system cannot read your code. Since the jQuery program acts as a bridge between the two, you will have to find a way to fix it or use another file.

Potential Reasons for a ‘jQuery Not Defined’ Error

Though it is easy to fix, finding out the reason for it might be a bit tricky. Though the first reason is likely an incompatible code, others include the following,

1. CDN Performance

If you’re using a CDN, then it is likely that it is unable to reach your server, especially if you are using it to improve your browsing experiences. If you do not have a CDN, then this doesn’t apply.

2. JavaScript Functioning

If your JavaScript loads and operates faster than your jQuery, then ensure that it does so simultaneously. A faulty JavaScript might also be the reason that the WordPress jQuery is not defined warning pops up on your blog.

3. jQuery Error

Though rare, a problem with your jQuery, such as a typo or internal error, is the reason for the problem. Perhaps a core file or a plugin might have caused a conflict with other components of the program and is the reason your WordPress jQuery is not defined.

4. Outdated Plugins

Sometimes, old plug-ins that you have installed in your computer tend to conflict with new ones that you have installed and activated recently. Both newly activated plug-ins or those that you have not updated recently can become a reason for the ‘jQuery not Defined’ or ‘uncaught reference error’ notification on your WordPress is triggered.

5. Slow Hosts

If you suspect that you have slow server or server resources, then a quick look at the error log can confirm this for you. Laggy or faulty hosting environments can also be a cause for the slow or stilted functioning of your jQuery, prompting that error.

Three Methods to Fix a ‘jQuery Not Defined’ in WordPress

Three Methods to Fix a ‘jQuery Not Defined’ in WordPressWhether your site is down or you need to give your console a quick check-up for errors, a WordPress ‘jQuery is not defined’ alert must be resolved as quickly as possible. And this is quickly done because it is one of the most easily solved and straightforward solutions to a technical error with your files. There are multiple methods to fix this error; however, make sure that you always backup your website before you start to deal with any sort of code.

1. Snippet Method

Though this is a simple method, it does have to be executed perfectly for it to remove the ‘jQuery Not Defined’ error. All you need to do is to open your File Manager, locate the ‘+public_html’ folder and look for the ‘wp-config.php’. Open the folder and add the following snippet to it.

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
define('CONCATENATE_SCRIPTS', false);

Do not cut out the ‘define’ statements and this should resolve your issue.

2. Include Google Hosted jQuery

If you include a Google-hosted jQuery with your JavaScript with an alert/local fallback; this will eliminate any CDN-related problems.

First load the jQuery program from Google’s CDN:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

If it doesn’t work, then or the CDN is unsuccessful, then fall back to a local copy of jQuery:

<script>window.jQuery || document.write('<script src="https://mysite.com/jquery.min.js"><\/script>'))</script>

This issue has been provided by the jQuery official website. This means that if your WordPress jQuery is not defined due to loading problems, then your local domain will prove to be successful.

3. Insert the jQuery Library

If the first two solutions have not been successful, then you must open your ‘header.php’ file. To do this, you must:

  • Go to the Google-hosted library and copy the entire jQuery library. However, make sure that it is the latest version of it
  • Go to your ‘Themes’ folder and locate the ‘header.php’ folder.
  • Add in the copied library but make sure that it is after the header tag
  • Save your file

Ensure that your jQuery is Loaded

This is an important step and saves a lot of time. Before you work on any of the solutions stated above, make sure that your jQuery loaded properly; you might need to see the Source Code for this. Keep the CTRL+U shortcut, since it is important to keep the jQuery properly referenced and defined in the code. This is why JavaScript loading is important for jQuery functioning.

These are only a few common solutions for the jQuery not-defined error that WordPress users seem to face. Since it is a common problem, you should be able to fix it and easily browse through your website again.

Conclusion

Remember, this problem only occurs when your browser cannot link with your jQuery library. To resolve this, there are a number of solutions that you can opt for, but most of these are successful, as reported by users. Most WordPress users have successfully resolved the ‘jQuery Not Defined’ issue within their computers, using the solutions mentioned above.

If you are looking for a seamless, bug free custom website development services, get in touch with our consultant waiting for you live to chat now!

Arturo Digital

Arturo Digital – An American technology firm providing Mobile Application Development, Website Development, Large/Small Ecommerce Stores, Website Portal Development & Digital Marketing Solutions for Entrepreneurs, Business Owners and Future Technologists alike. 

No Comments Yet

Leave a Reply

Your email address will not be published.

    GET IN TOUCH WITH US