Bobcares

Wp_enqueue_script jQuery is not defined | How to resolve

by | Sep 17, 2022

Wp_enqueue_script jQuery is not defined, fix this error by following the simple steps given by our support team with the help of WordPress Support Service at Bobcares.

What Is the “jQuery Is Not Defined” Error?

This error is meant to be that your site may be a plugin that requires jQuery to function. For some reason, the function was not available when the browser tried to load the website and called for that specific jQuery.

This error has the potential to shut down your site for visitors. Because 78% of the sites on the internet run on jQuery, this is a common error to find.

Causes of the “Wp_enqueue_script jQuery not defined” Error

There are a few possible ways that the “jQuery is not defined” error might occur:

  • Old plugins installed on WordPress might conflicting with ones that you recently installed and activated, or if some activated plugins on your site have not been updated recently might cause the issue.
  • A slow performens environment could increase the amount of time for jQuery to perform when called, so need to Double-check your server resources or error log to confirm any slowness.
  • The JavaScript file is not being correctly accessible when the page loads or JavaScript on your website is running before the jQuery is fully loaded.
  • The CDN that used to improve your site performance might be unable to reach your server.
  • An error in your version of jQuery, perhaps someone recently edited a core file which might have caused a conflict.

How To Fix the “Wp_enqueue_script jQuery is not defined” Error

Here are some options to resolve this jQuery not defined error and get your site back up to visitors.

Method 1: Using Network Tab to Debug if jQuery Is Loading

At the Network tab of your browser’s dev tools, check if jQuery is being loaded. This initially gives you one place to search for quick validation. If the jQuery library isn’t included then add it to your wp_enqueue_script() function in the given snippet.

Locate the below code by going to the “wp-includes” folder, then open the script-loader.php file:

wp_enqueue_script( 'tt-mobile-menu', get_template_directory_uri() .
'/js/mobile-menu.js', array('jQuery'), '1.0', true );

Method 2: Make Sure jQuery Is Loaded

The other way is jQuery might have included but not loading by this, you may experience the “jQuery is not defined error”. So make sure that it’s loaded by finding the script source and pasting the URL in a new browser or tab.

For example, if the <script src= is set then, copy and paste the URL of the portion from http://—jquery.com–to–min.js into a new window or tab. If the jQuery file loads fine with entire contents, then you can check this off your list.

Method 3: Include jQuery With a Local Fallback

This is one of the great options to include with JavaScript because running jQuery on the localhost will improve website performance. It will also help to avoid any other CDN jQuery loading issues.

// Fall back to a local copy of jQuery
window.jQuery || document.write(''))

Method 4: Edit wp-config.php File

If none of the above you can add the given snippet function to the wp-config file :

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

Method 5: Insert the jQuery Library Manually

As a final method, you can update the header.php file and add the jQuery library:

  • Access Google Hosted Libraries and copy the latest version of the jQuery library in its entirety.
  • From the files section go to themes folder >> header.php file.
  • Next, add in the jQuery library from step one. Make sure the copied code must be added right after the head tag.
  • Finally, save the file.

[Looking for a solution to another query? We are just a click away.]

Conclusion

To conclude after these options, you should be able to resolve the “jQuery is not defined” error and access your site. Since this issue is typically due to the browser’s inability to connect with your jQuery library. Most people find results with any of the mentioned options.

PREVENT YOUR SERVER FROM CRASHING!

Never again
lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server
24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.