jQuery Is Not Defined WordPress Solution


Are you getting “Uncaught ReferenceError: jQuery is not defined” error in WordPress ? It is one of the common WordPress jQuery error. “jQuery is not defined” error needs some debugging and can be fixed.

What causes “Uncaught ReferenceError: jQuery Is Not Defined” error in WordPress ?

There might be multiple reasons why are you getting error related to jQuery in your WordPress theme or plugin. Below are some of the common reasons

Solution to jQuery not defined in WordPress
  1. jQuery file loading issue
  2. JavaScript/jQuery code sequencing

Solution to “Uncaught ReferenceError: jQuery Is Not Defined” error in WordPress ?

If you are loading jQuery from CDN or some other domain then don’t forget to check whether the jQuery file is loaded or not. Sometimes there might be some security permissions specified in configuration of your web server. Please check if you have given permission to load resources from third party websites.

Check if your code from theme or plugin is loading prior to jQuery plugin loading. Sometimes the plugin code gets executed before loading the jQuery, so make sure that have jQuery loaded before doing any processing.

So if you have a plugin where you are using WordPress wp_enqueue_script function to load your JavaScript file. Then don’t forget to specify dependency to be available before loading your JavaScript file. You can add your JS file using following syntax and add dependency using “array(‘jquery’)” as a parameter.

wp_enqueue_script("yourjsfile","jspath",array('jquery'), true);

Also do not forget to write your code inside $(document).ready function to avoid any pre execution.

If you are getting “Uncaught SyntaxError: Unexpected token switch” error in JavaScript then don’t forget to find the solution here.

ProWebGuru: Mostly I write about technology related stuff on https://www.prowebguru.comRecently I have started making videos also. Mostly blog posts & videos are related to technology, programming and learning some new tips and tricks related to windows, wordpress, google app script, technical, programming, javascript, jquery and other coding related stuff.Youtube channel - https://www.youtube.com/user/prowebguru

This website uses cookies.