Where does JQuery library reside?
Does the JQuery library reside in the browser such that it executes the underlying JS from the library? Or is the JQ library code included in my server-side code when I publish? It sure makes more sense to me that it be only on the browser side to reduce the bandwidth.
Sorry for the (probably ) stupid question but I just cannot seem to find an answer with all my searches.
JQuery is client-side. That means that it's loaded with your HTML and other assets your page requires. It runs in the browser and not on the server.
Bandwidth is another question entirely. Depending on which JQuery library you are calling it could be anywhere from 80 to 100+ kb of bandwidth. One of the advantages (in my mind) of calling a library from a central repository such as Google rather than hosting it on your site is that a user has probably been to another site using the same library. Therefore there's next to no bandwidth used since it gets loaded from their browser cache. The bandwidth used is whatever plugin script you have that uses the library.
It's still another HTTP request no matter what. If the library is in cache it will load from there but the server still has to handle the request and send a response (304). If not in cache the file/library gets sent.
Hope I didn't confuse you
Thank you for the response Kevin! So wait...you mean the browser(client), when it parses a JQ request, may have to go out and ask an external server(JQuery.com0 to figure out the JQ? I was thinking the browser machine might have a local copy of the JQ library and just access it from the hard drive? No, you make complete sense. Just trying to understand what is going on. This is stuff I do not see when JQuery is explained. Thanks!
That being stated, having the JQuery file in the browser cache is almost like having it "built in" to the browser in that it doesn't have to be downloaded again. That's the reason for calling a library from a central repository like Google or JQuery.com. In all likelihood, your user has been to another site using the same library from either Google or JQuery and the file already is "built in" to their browser and doesn't have to be downloaded again. However if you host that library on your site the browser thinks it's a different library, even if it has the same filename, and downloads it again.
A real world example: I have a photo gallery script on a couple of sites that uses HTML5, CSS3, and JQuery to present thumbnails and full-size photos in a really slick display. I call the JQuery library like this:
But if I was hosting it on my site the code would look something like:
To a browser those are 2 different files, even if the contained code is exactly the same. The link to googleapis would probably return a 304 to a browser and the file would load from cache. The "local" link would download the library from your site the first time a user hits a page needing it.
More confusion, I suppose. Sorry for being so wordy...
Interesting. And it makes complete sense, Kevin. Thank you for taking part of your Christmas Day to 'edumacate' me!
I don't know how much of an "edumacation" was provided, but for what little there was you're welcome!
Merry Christmas -- what's left of it!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)