jQuery Tutorial

What is jQuery CDN? How to Use CDN for jQuery?

What is CDN?

CDN stands for Content Delivery Network. It is a geographically distributed group of servers that collaborate to deliver online content quickly to the end-users. To respond directly to end-user requests for web content fast and securely, the Content Delivery Network is dispersed across many physical and network locations.

A CDN provider is a company that allows businesses to serve their content to end users all over the world, at the same speed. CDNs speed up page loads and provide several other advantages, including the following:

  • Increasing the speed with which websites load

  • Lowering the cost of bandwidth

  • Increasing the availability and redundancy of content

  • Improving the safety of your website

Is there a CDN for jQuery?

Web programmers can use CDN to host their jQuery library for faster access and better performance. Fortunately, both Microsoft and Google have jQuery hosted on CDNs. 

How to Add jQuery in HTML Page?

You can insert jQuery in HTML file using two methods:

  1. By downloading the jQuery library (Offline)

  2. Using CDN

Downloading jQuery Library and Adding to HTML

If we want to add jQuery to an HTML page, we must first download the jQuery file and follow the steps outlined below. Any user can easily add jQuery by following these steps.

  1. First, download the jquery.js file from the official jQuery website

  2. After downloading the file, open the html file in which we want to include the jquery code.

!doctype html>     
    
  
  
   
hello learner!... 
  
   
   
  

3. Next, we need to navigate the cursor between the head and title tags. Then use the script> tag to specify the src attribute for including the jQuery file.

!doctype html>     
    
  
  
  
   
hello learner!... 
  
   
   
 

4. Now, save the html file. It will add the jQuery library to HTML.

Include jQuery in HTML with CDN

If we want to use CDN to add jQuery to an HTML page, we should follow the steps outlined below. Any user can easily add jQuery by following these steps.

  1. First, open the html file where we want to use CDN to add jQuery.

!doctype html>  
<html>     
<head> 
 <script type="text/javascript" src=>  
</script>  
<title>     
insert jquery file to html using cdn
</title>  
</head>  
<body>   
hello learner!... <br> <center>  
<img src="https://www.tutorialsfreak.com/_nuxt/img/6ce6778.svg" width="100" height="100" > </center>  
</body>   
</html> 

3. Now, in the src attribute, add the following path.

http://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js  
!doctype html>  
<html>     
<head> 
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">  
</script>  
<title>     
insert jquery file to html using cdn
</title>  
</head>  
<body>   
hello learner!... <br> <center>  
<img src="https://www.tutorialsfreak.com/_nuxt/img/6ce6778.svg" width="100" height="100" > </center>  
</body>   
</html>

4. Lastly, save the html file. It will add the jQuery to html with CDN.

Did you find this article helpful?