Tijmen
Tijmen

Reputation: 641

Getting "ReferenceError: jQuery is not defined" for jQuery files included in Wordpress as well as the CDN

Firebug was giving me the ReferenceError: jQuery is not defined error for the jQuery-Migrate file included with the latest version of Wordpress.

original HTML:

<script type='text/javascript' src="http://www.potgieter.nl/wp-includes/js/jquery/jquery-migrate.js?ver=1.4.1"></script>

Error:

ReferenceError: jQuery is not defined
})( jQuery, window );'

After looking around on SO and other sites, I found several people suggesting to use the jQuery CDN at http://code.jquery.com/ By the looks of it their version is newer, but I figured the worst case scenario that would give a new error.

I grabbed their code and used that instead, but I'm still getting this error.

new HTML

<script src="https://code.jquery.com/jquery-migrate-3.0.0.js" integrity="sha256-lsVOB+3Yhm6He5MkTO3Bw/Xw4NXK7wYYTi1Y+M/2PrM=" crossorigin="anonymous"></script>

same error

ReferenceError: jQuery is not defined
})( jQuery, window );

What's going on here? I can't imagine there's a bug in the official CDN, and I'd image that the files included in Wordpress should not be bugged either, so what am I missing here?

Edit: image for context https://i.sstatic.net/PhUjl.jpgenter image description here

Upvotes: 1

Views: 2132

Answers (1)

Tijmen
Tijmen

Reputation: 641

jQuery.js needs to be loaded before any other jQuery migrate, because that's where jQuery gets defined. If jQuery isn't defined, the system won't know what to do with jQuery migrate, and it won't work.

Upvotes: 1

Related Questions