Worth it to use jQuery UI hosted by Google?
So I heard good reasons why to use the 开发者_开发知识库jquery hosted on google because of caching. But I am not sure about jQuery UI though.
I am guessing that the jQuery UI file hosted on google has every single extension and plugin (such as Draggable, etc).
So is that not kind of a waste if say your only using only jQuery UI tabs? to get all that other stuff with it.
Also I see they have some of the templates up for the css files. I am guessing the caching would be the main advantage of using the hosted file.
It's worth it. The blog post for jQuery's last update used the word "performance" more than any other -- and for good reason. The library isn't small, so performance can be a problem.
Hosting your .js on Google is one way to count on jQuery being the lingua franca of the JavaScript world and it could save you valuable download time in browser. Remember, scripts block parallel downloads so any time your user spends downloading the .js from you is time they can't spend downloading something else.
The downfall is that Google could perhaps go down, but there's already industry talk about redundancy and roll-over servers to mitigate that concern.
That depends. If the file is already in the user's cache then it's going to be quicker than downloading the independent class from your server because parse speed > download speed. If the google-hosted file isn't cached by the user then, assuming a connection rate matching Google's servers (not taking into account saving the DNS lookup :-)), it would be quicker to fetch it from your own server.
Google properly sets up caching the JQuery library for the widest possible range of browsers, using Cache-Control
, Last-Modified
, Expires
, Age
, and Date
. It'll reliably cache on every common browser. In addition to this, the server is geo-locational - the user will always do the initial download from the closest possible server to them.
And as @editor said, browsers will block parallel resource downloads from the same hostname. Your sites javascript will download in parallel at the same time as the JQuery library downloads from googles domain giving you those additional precious milliseconds :)
You also delegate the bandwith costs to Google. Say 10000 unique vistors hit your page each day - thats a minimum of ~30Mb. A month? ~878Mb. A year? ~313Gb.
精彩评论