Uncaught Reference Error $ is not defined

JKP84
Tourist
12 0 9

I am receiving the above error when i inspect my site. it appears to be referring to the following (the line in bold/red) in my theme.js file:

var adjustStyleAndPosition = theme.Helpers.debounce(function() {
styleDropdowns(document.querySelectorAll(selectors.siteNavHasDropdown));
positionFullWidthDropdowns();
$(selectors.multicurrencySelector).on('change', function() {
$(this)
.parents('form')
.submit();
});
}, 50);

and this one:

var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};

can anyone help me out with fixing this?

Thanks

 

0 Likes
gina-gregory
Shopify Expert
710 47 168

That error means that jQuery is not loaded on the site when that code runs. This could either be because jQuery is not added to the theme at all or it is deferred and loading AFTER this code runs.

0 Likes
JKP84
Tourist
12 0 9

Thank you @gina-gregory - is this a big issue that will affect the site functioning?

0 Likes
gina-gregory
Shopify Expert
710 47 168

Yes, any code dependent on jQuery will not work if the jQuery library is not present when it tries to run.

0 Likes