www.webdeveloper.com
Results 1 to 4 of 4

Thread: Is it better to load things from google's CDN??

  1. #1
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242

    Is it better to load things from google's CDN??

    Say I use jQuery, is loading it from googleapis.com:
    HTML Code:
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    generally better than using a copy from the machine hosting most of my site:

    HTML Code:
    <script src="/js/jquery.min.js"></script>
    ?

    Pros/cons of using CDNs vs. getting the resource "locally"?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,139
    Two things come to mind, one good and one not so good. The good part is that by relying on Google's server means there's potentially a (very) small increase in page loading speed because it's in a separate namespace. The not so good part is that you're relying on a specific version of jQuery. In the end, using Google's server is probably the superior choice, but the differences either way are miniscule.
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    I found it better to search for "pros and cons google hosted jquery", so found some answers. To summarize the benefits of pointing to googleapi.com are "decreased latency, increased parallelism, and better caching."

    Since you're loading a commonly used URL ("//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" in the case of jQuery) it's possible (or likely) it's already been loaded and cached. Excellent!

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    And, that way Google can keep track of every site that is using it.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles