Uncaught ReferenceError: jQuery is not defined: how to fix on a sunday? [closed]

It’s a very bad idea to deregister jQuery and re-register it to a CDN, and it does not improve performance. It can also cause issues due to mismatched jQuery versions. If you want to use jQuery on your site, just enqueue the jQuery that comes with WordPress.

As Anoop says:

You are loading jQuery async means, you are telling the browser, that’s it’s ok to load jQuery anytime, either early or later, so it makes sense that in some cases, it loads after page load and thus jQuery is undefined . Removing the async will make it work

So remove the script tag, and enqueue jQuery normally, and the issue should improve.


For reference, this did improve performance back in the early 2000’s, but the browser cache key now contains the domain so if you load the CDN on a new site you get a new copy, it doesn’t load the version it already downloaded ( which was the idea behind shared CDN improving performance ).

It also means HTTP2 optimisations can’t be used to transfer the file faster since it’s on a separate domain/server. Since it was a popular change it’s stuck around even though it doesn’t help anymore