This error simply means that you’re using jQuery but it is not present. If jQuery is indeed installed, you are loading your jQuery custom code before jQuery is properly loaded.
What I’d personally do in a case like this is making the custom code async.
This way you can wait for jQuery to load and only afterwards run your own code:
(async () => {
while(!window.hasOwnProperty("jQuery")){
await new Promise(resolve => setTimeout(resolve, 50));
}
console.log("jQuery is loaded. Run custom code below.");
})();
Note that this is a fairly crude solution that may need to be enhanced/adapted for your specific case. You may want to break the “while” loop after a certain number of tries.
I am doing the same job right now for a client that asked me to upgrade Impulse 3.x to 4.x and yes, you are right, JQuery is not used anymore on Impulse since 4.x.
Now, the first thing you can do to fix the store and not break it is to add jQuery again.
So download the latest version of jQuery minified, add to the asset folder of you theme and add the following line of code to theme.liquid inside block
Of course by adding this dependency you slow down the website.
I have also to warn you that many Shopify apps still relies on jQuery.
Some of them add their version, other give for granted that jQuery is used in your theme.
I suggest you to create a clone of your theme and start debugging it in Preview mode to search which Javascript code still depend on jQuery and try to convert it to vanilla JS.
Thanks for the solution. Almost all above mentioned solutions works but there are chances they may fail for any browser or version. Some of the code I already did in vanilla JS. But I prefer not to touch 3rd party apps code.
As I found that $(document).ready(function(){}); equivalent in JS has browser compatibility issue in some forum answers. So I have decided to add the jQuery file again.