/    Sign up×
Community /Pin to ProfileBookmark

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

Say I use jQuery, is loading it from googleapis.com:

[code=html]<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>[/code]

generally better than using a copy from the machine hosting most of my site:

[code=html]<script src=”/js/jquery.min.js”></script>[/code]

?

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

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyJan 17.2012 — 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.
Copy linkTweet thisAlerts:
@handcraftedwebauthorJan 17.2012 — 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!
Copy linkTweet thisAlerts:
@WolfShadeJan 17.2012 — And, that way Google can keep track of every site that is using it.
×

Success!

Help @handcraftedweb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...