Google JQuery CDN

Google JQuery CDN

Google JQuery CDN Here we will see how and why should you use content delivery network to get Jquery scripts. Google supports JQuery hosted on their CDN network. Let’s see benefits of using Jquery hosted on CDN.

First let me tell you what is CDN. It’s a content delivery network or content distribution network. The contents like images,scripts,urls are cashed or stored across nodes of networks. Whichever node is closer to your system serves the request.

  1. Jquery script is coming from CDN, as a result it get cashed in end user browser.
  2. Browser need not send another requests to get Jquery content as it’s already in cache.
  3. Reduce load on your system.
  4. Easy to deal with versioning issues of JavaScript.

Here is Google Jquery Link that you need to add in your header section of the page.

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

Next, you need to load the Jquery in your page. use google.load method to load specific version of Jquery.

<script type="text/javascript" language="javascript">
    
    google.load("jquery", "1.7.1");   
    
    </script>

Let’s test the code by calling simple alert function.

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

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

<script type="text/javascript" language="javascript">

google.load("jquery", "1.7.1");   

$(document).ready( function (){ 
                     alert('ok'); 
                    });

</script>

If you want always load latest version of Jquery, use below method of google object.

google.load("jqueryui", "1");

You may want to load the Jquery script directly without using google.load method.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
   
   <script type="text/javascript" language="javascript">
   
  
   
   $(document).ready( function (){ 
                        alert('ok'); 
                       });
   
   </script>

Tags:

How to use Google analyticsBasics of jqueryLearning JqueryJQuery Animate Div Height and WidthJQuery SlideJquery Trim StringDisable Google Suggesthow to remove Google ChromeJQuery Form With ValidationHow to call function in JQueryJQuery Hello World Example

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.