Where to load jQuery

Open to all! Ask other shopowners for help.
Post Reply
ArtcoInc
Contributor
Posts: 119
Joined: Fri Oct 25, 2019 4:19 pm
Phoenix Version: v1.0.3.0
Has thanked: 86 times
Been thanked: 17 times

Where to load jQuery

Post by ArtcoInc »

(For those of us still on old versions of Phoenix, and still using jQuery ...)

Where is the best place on a page to load it? When I had it loading in the footer, I was getting error(s):

Uncaught ReferenceError: $ is not defined

When I moved loading it up in the header, these went away (and resolved some other problems I was having).

Is there a problem with loading jQuery in the header instead of the footer?

TIA

Malcolm

Tags:


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Where to load jQuery

Post by burt »

Wherever. In admin of 1.0.3.0 it is loaded in header.
In shop it is loaded in Footer via Hook.

Where it is loaded will affect the speed your site loads.
You simply need to make sure that any jQuery usage comes after jQuery is loaded.

Or...don't use jQuery at all, which is the preferred solution, but would be a lot of work to achieve in v1.0.3.0
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply