If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Where does JQuery library reside?

I have admit that I am complete noob on all of this. I am trying to learn HTML5, Javascript, CSS, JQuery, etc.

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.

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!

If you are calling a JQuery library that a user does not have already in their browser cache it does download it from whereever your page calls it from. The browser does not come with JQuery preinstalled, but it will execute the code once downloaded and requested. JQuery is really a library of JavaScript that can be leveraged via plugins. So it acts somewhat like JavaScript in that it has to be called, loaded and executed.

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:

Code:

<script type="text/javascript" src="/assets/jquery.min.js"></script>

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.