jquery is the most common and popular JavaScript library in front-end development, how to load it to make our projects more performance and ask what to use CDN? When users visit their own site loading files from the server, each server can only download 2-4 files, which will reduce the efficiency of the file execution, if more than a few servers, so that the number of simultaneous loading of files is (2-4) * The number of servers, So we put jquery on a CDN to improve the efficiency of loading files on our website. Let's talk about the usual jquery Cdn.
Introduction to CDN:
Baidu Encyclopedia on the introduction of this:
The full name of the CDN is the Content Delivery network, which is the contents distribution networks. The basic idea is to avoid the bottleneck and link of the Internet which may affect the speed and stability of data transmission, and make the content transmission faster and more stable. By placing the node servers in the network, a layer of intelligent virtual network based on the existing Internet, the CDN system can re-direct the user's request to the nearest service node according to the network traffic and the connection of each node, the load condition and the distance and response time of the user. The goal is to enable users to get the content they need, solve the congestion of Internet networks, and improve the responsiveness of users to websites.
Advantage:
- Do not worry about your site visitors, at any time, any location, any network operator, can quickly open the site.
- Various server virtual host bandwidth and other procurement costs, including the late operation and maintenance costs will be greatly reduced.
- To the site directly bring the benefits of: traffic, consulting volume, customer volume, into a single volume, will be greatly improved.
CDN From abroad:
- Google Hosted Libraries
Src= "Http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
- Microsoft CDN
Src= "Http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.0.min.js"
- Cdnjs
Src= "Http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"
- jquery Official website
Src= "Http://code.jquery.com/jquery-1.11.0.min.js"
- Jsdeliver
Src= "Http://cdn.jsdelivr.net/jquery/2.0.0/jquery-2.0.0.min.js"
It can be seen that the fastest foreign CDN is CDNJS
CDN in China:
- Baidu
Src= "Http://libs.baidu.com/jquery/2.0.0/jquery.min.js"
- Seven cows
Src= "Http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"
- Sina
Src= "Http://lib.sinaapp.com/js/jquery/1.6/jquery.min.js"
- and shoot the clouds.
Src= "Http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.0.min.js"
- 360
Src= "Http://libs.useso.com/js/jquery/2.0.0/jquery.min.js"
You can see the fastest in the country is seven cattle
Summarize:
In addition to foreign Google and CDNJS services, the domestic library does not support the HTTPS environment, unfortunately, the domestic users are relatively slow to load, if their own site set up in foreign countries can give priority to use. If the CDN fails to load, we need to load our own local jquery file, just add the following code to the head to
1 <Scripttype= "Text/javascript"src= "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></Script>2 <Script>Window.jquery||document.write ('<script src= "js/jquery-1.11.1.min.js" type= "Text/javascript" ><\/script>')</Script>
The speed test above is local, with the network and bandwidth and so has a great relationship, it is best to re-test these CDN in their own environment, if you have other CDN can @me, hope this article can help you.
The CDN performance of 10 Domestic and international jquery