JQuery not working in Mozilla

 ReferenceError: jQuery is not defined
[Learn More]
26938.js:5:1
JQMIGRATE: Migrate is installed, version 1.4.1

Learn more has this link

Background:

As far as I know, then the Wordpress core has JQuery so in my theme normally I do not include a separate JQuery, and all the sections work well in chrome without including a sperate JQuery in the theme.

But Mozilla is throwing an error and some features of the theme don’t work.

enter image description here

This is how we include a javascript in the Wordpress.

enter image description here

A quick google search reveals this answer:

Add wp_enqueue_script('jquery'); before you enqueue your scripts.

1 Like

I think the correct process for that would be to deregister JQuery first and the register it as you suggested, but deregistering JQuery is not an advocated practice.

Here are two references:

Reference #1
Reference #2

A no conflict mode is discussed here. Maybe that could be the solution to my problem.

To J Nowell has given this solution here →
It likely doesn’t work because jQuery is in no conflict mode and you need to use jQuery(…) rather than $(…) or use an appropriate wrapper – Tom J Nowell

what does that mean using an appropriate wrapper?

But I think the issue here is that JQuery is working, but showing an error in Mozilla console where it is not working.

Hm no the way you registered your script looks alright… also if it was a backend issue, it wouldn’t work in chrome either. You might disable caching there though, just to rule that out. And as for noconflict mode, if this was the problem I think you’d get an error that $ is not defined, not jQuery.

Could you maybe provide a link so that we can inspect the sources?

2 Likes

I think it is fixed now →

When you enqueue script that is dependent on jQuery, note that the jQuery in WordPress runs in noConflict mode, which means you cannot use the common $ alias. You must use the full jQuery instead. Alternately, place your code using the $ shortcut inside a noConflict wrapper.

jQuery( document ).ready( function( $ ) {
    // $() will work as an alias for jQuery() inside of this function
    [ your code goes here ]
} );

#Previously it was like this:

( function( $ ) {
    // $() will work as an alias for jQuery() inside of this function
    [ your code goes here ]
} );

so was not working somehow in Mozilla.

#so for the Future visitors:

Please be informed that this extra bit is added:

jQuery( document ).ready

It looks like its fixed else for sure I would have provided you (and @Paul_Wilkins ) in a PM(because some privacy and copyright issue associated with the links: content, design etc)

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.