This means that generally speaking, you should keep jQuery loaded in the header, and this slows down your page rendering. Just trust me on this. For this reason, I want to use every means possible to speed up the delivery of jQuery. And for that, publicly hosted libraries are the best. Perhaps the biggest difference between a traditional CDN network and a public library, is that the former is accessed by only your website, and the latter is accessed by thousands — even millions — of people.
Browsers typically cache the JavaScript they receive for differing periods of time — even up to a year! It can simply use its cached copy and bypass the process entirely. This is the absolute best-case scenario for us. But for this, we need to use well-known public libraries that everyone else is using.
A private CDN will not bring the same caching and performance benefits. This is one huge advantage in favor of public hosted libraries. Browsers cache not just files, but also DNS lookups.
So if millions of people are using a certain public library, the chances are that an average user will already have the DNS entry in their browser, and thus avoid the lookup altogether. This sidesteps the penalty of DNS lookups.
But again — it will only work with a public hosted library where everyone uses the same URL. Skip to content. Star Permalink master. Branches Tags.
Could not load branches. Could not load tags. Raw Blame. Open with Desktop View raw View blame. Just here for the links? If you care about older browsers, primarily versions of IE prior to IE9, this is the most widely compatible jQuery version: If you don't care about oldIE, this one is smaller and faster: Either way, you should use a fallback to local just in case the Google CDN fails unlikely or is blocked in a location that your users access your site from slightly more likely , like Iran or sometimes China.
Decreased Latency A CDN -- short for Content Delivery Network -- distributes your static content across servers in various, diverse physical locations.
Increased parallelism To avoid needlessly overloading servers, browsers limit the number of connections that can be made simultaneously.
Implementation Note: At the time I originally wrote this, Google used to recommend this loader approach, but no longer does. Of the two methods available, this option is the one that Google recommends: The google. For example: While there's nothing wrong with this, and it is definitely an improvement over hosting jQuery locally, I don't agree that it offers the best performance.
Firebug image of the longer loading time caused by jsapi As you can see, loading, parsing, and executing jsapi delays the actual jQuery request. Back to basics In the face of those drawbacks to the google. For example: Not only does this method avoid the jsapi delay, but it also eliminates three unnecessary HTTP requests. I no longer recommend that approach. Conclusion According to a recent study, Google will consume You signed in with another tab or window.
Reload to refresh your session. You signed out in another tab or window. Libraries To load a hosted library, copy and paste the HTML snippet for that library shown below in your web page. You must also load jQuery before loading this module. Version 1. Before loading this module, you must load Prototype. If you encounter problems: Look for typos.
Remember that JavaScript is a case-sensitive language.
0コメント