Updated February 21, 2023
Definition of jQuery Ajax CDN
jQuery ajax CDN provides popular third-party JavaScript libraries like jQuery; it will allow us to integrate them into our Web applications quickly. Add a script tag to our page that points to the ajax website to start utilizing jQuery, which is hosted on this CDN. We can use a CDN (Content Delivery Network) to get jQuery if we don’t want to download and host it ourselves.
What is jQuery Ajax CDN?
- We may dramatically increase the performance of our Ajax applications by using the CDN. The CDN’s material is cached on servers all over the world.
- If we need to deliver a web page that uses the Secure Sockets Layer, the CDN supports the SSL.
- The third-party script libraries listed below have been uploaded to the CDN and are licensed to us. By the library proprietors.
1) jQuery
2) jQuery User Interface
3) jQuery Mobile
4) Validation with jQuery
5) jQuery Cycle
6) jQuery data tables plugin.
- The Microsoft Ajax CDN also includes the libraries listed below, which were Microsoft uploaded.
1) Ajax in ASP.NET
2) JavaScript Files for ASP.NET MVC
3) JavaScript Files for ASP.NET SignalR
- Microsoft does not own any third-party libraries which were hosted on the CDN. Instead, these libraries are licensed by the copyright owners of the libraries.
- Because these aren’t Microsoft libraries, Microsoft doesn’t offer any warranties or intellectual property rights licenses for the third-party libraries housed on this CDN. Therefore, any rights to download and utilize such libraries are granted solely by the copyright owners.
- The CDN previously used the Microsoft domain name; however, it has now been replaced with aspnetCDN.
- This adjustment improved performance since cookies from the Microsoft domain were sent across the wire with each request when a browser accessed that domain.
- The CDN also contains a minified version of the jQuery script; if the CDN is unavailable, fall back to fetching jQuery from a local location.
- We can add the element referencing the CDN to allow our page to default loading jQuery from a local route on our website if the CDN isn’t available.
- The jQuery UI library is also available from the CDN. We may use the jQuery UI library in our ASP.NET apps to create a variety of widgets and effects.
How to use jQuery ajax CDN?
- A content delivery network (CDN) is a global network of proxy servers that allows users to view cached information from multiple locations. It contains pictures, CSS, and javascript files, among other things.
- The primary goal of a CDN is to reduce the physical distance between end-users and the website’s hosting servers. As a result, the time it takes for the material to render and the speed with which it loads have improved.
- JQuery is a powerful JavaScript library that makes using JavaScript on our site easier. Unfortunately, it takes time and increases latency to download the jQuery library from our server, but if we don’t want to host it ourselves, the ideal approach is to use a CDN.
- All we have to do now is include the script in our code. Then, we can use either Google’s or Microsoft’s jQuery to include it.
Below is the code to include jQuery by using Google CDN as follows.
Code:
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/jQuery/3.3.1/jQuery.min.js">
</script>
</head>
Below is the code to include jQuery by using Microsoft CDN as follows.
Code:
<head>
<script src = "https://ajax.aspnetCDN.com/ajax/jQuery/jQuery-3.3.1.min.js"></script>
</script>
</head>
- When we use the jQuery CDN, we accomplish two goals, i.e., the jQuery file is loaded through a CDN rather than our website, and the load on our website is reduced.
- CDNs deliver jQuery faster than our server. In addition, because CDNs are built for speed, they offer jQuery to users from the closest location.
- CDNs use data servers and load balancing algorithms to ensure that jQuery is served quickly.
- This network of servers is scattered across several physical and network locations to respond quickly and securely to end-user requests for online content and media delivery.
- While a CDN does not host material and cannot completely replace the requirement for conventional web hosting, it can aid in caching content at the network edge, enhancing website speed.
- A content delivery network (CDN) provider is a company that allows businesses to provide their content to end customers all over the world. CDNs speed up page loading times and provide a variety of other advantages.
- Web programmers can use CDNs to host their jQuery Library for faster access and enhanced performance.
- Fortunately, jQuery is already hosted on Microsoft and Google’s CDNs. So now, all we have to do is refer to the jQuery library hosted on the server.
jQuery ajax CDN examples
The below example shows jQuery ajax by using Microsoft CDN:
Code:
<!DOCTYPE html>
<html xmlns="http://www.abc.org/xhtml">
<head>
<title> JQuery Ajax CDN </title>
</head>
<body>
<button id = "btn"> Click on this button to display the message </button>
<div id = "message" style = "display:none">
<h1> jQuery ajax by using Microsoft CDN </h1>
</div>
<script src = "https://ajax.aspnetCDN.com/ajax/jQuery/jQuery-1.9.0.min.js"></script>
<script>
(window.jQuery || document.write('<script src = "https://cdn.educba.com/scripts/jQuery-1.9.0.min.js"><\/script>'));
</script>
<script>
function domReady () {
$('#btn').click( showMessage );
}
function showMessage () {
$('#message').fadeIn ('slow');
}
$(domReady);
</script>
</body>
</html>
The below example shows jQuery ajax by using Google CDN:
Code:
<!DOCTYPE html>
<html xmlns="http://www.abc.org/xhtml">
<head>
<title> JQuery Ajax CDN </title>
</head>
<body>
<button id = "btn"> Click on this button to display the message </button>
<div id = "message" style = "display:none">
<h1> jQuery ajax by using Google CDN </h1>
</div>
<script src = " https://ajax.googleapis.com/ajax/libs/jQuery/3.3.1/jQuery.min.js "></script>
<script>
(window.jQuery || document.write ('<script src = "https://cdn.educba.com/scripts/jQuery-1.9.0.min.js"><\/script>'));
</script>
<script>
function domReady ()
{
$('#btn').click( showMessage );
}
function showMessage ()
{
$('#message').fadeIn ('slow');
}
$(domReady);
</script>
</body>
</html>
Conclusion
jQuery ajax CDN provides popular third-party JavaScript libraries like jQuery. A content delivery network (CDN) provider is a company that allows businesses to provide their content to end customers all over the world. JQuery ajax CDNs speed up page loading times and provide a variety of other advantages.
Recommended Articles
This is a guide to jQuery Ajax CDN. Here we discuss the definition, What is jQuery Ajax CDN, and How to use jQuery ajax CDN with example and code implementation. You may also have a look at the following articles to learn more –