Search code examples
jquerydownloadhyperlinkpack

jQuery Linking vs. Download?


Which way is better? To link to the jQuery Pack at http://ajax.googleapis.com. Or to download the appropriate file and link locally? Does it matter? Is there a chance the link may disappear? Or is there a chance the file online will be updated, and it's better to link to it? Curious.

Thanks, Tracy


Solution

  • From the Google Code site:

    Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.

    One of the main points of Google hosting the jQuery library is so that it is cached in a single place. Consider the following scenario:

    1. User visits site A
    2. Site A has jQuery on the same domain, so the file is downloaded by the browser
    3. User visits site B
    4. Site B has jQuery on the same domain, so the file is downloaded by the browser a second time.

    Now if we all fetched jQuery from the Google servers, the scenario goes like this:

    1. User visits site A
    2. Site A loads jQuery from Google, so it's downloaded by the browser
    3. User visits site B
    4. Site B loads jQuery from Google, but the browser already downloaded it and cached it, so fetching the file again is instantaneous.