web analytics

Using a content delivery network (CDN) to load common Javascript libaries in your website

Options

codeling 1599 - 6654
@2020-01-17 09:38:30

One of simple and common technique to improve your website performance is to use content delivery network (CDN). A public CDN is a website that hosts commonly used files, such as Bootstrap or jQuery, which you can reference from your own apps. They have a number of advantages:

  • They’re normally stable and fast.
  • They save your server having to serve the file, saving bandwidth.
  • Because the file is served from a different server, it doesn’t count toward the six concurrent requests allowed to your server in HTTP/1.0 and HTTP/1.1.
  • Many different apps can reference the same file, so a user visiting your app may have already cached the file by visiting a different website, so may not need to download it at all.
@2020-01-17 09:46:34

Both Google and Microsoft host jQuery. To use jQuery from Google or Microsoft, use one of the following:

Google CDN

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>

Microsoft CDN

<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
</head>
@2020-01-17 10:12:10

The Microsoft Ajax Content Delivery Network (CDN) hosts the following popular third party script libraries:

It also includes the following libraries which have been uploaded by Microsoft:

  • ASP.NET Ajax
  • ASP.NET MVC JavaScript Files
  • ASP.NET SignalR JavaScript Files

The CDN used to use the microsoft.com domain name and has been changed to use the aspnetcdn.com domain name. This change was made to increase performance because when a browser referenced the microsoft.com domain it would send any cookies from that domain across the wire with each request. By renaming to a domain name other than microsoft.com performance can be increased by as much to 25%. Note ajax.microsoft.com will continue to function but ajax.aspnetcdn.com is recommended.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com