Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is a CDN in jquery?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 377
    Comment on it

    Hello Readers,

    CDN is a content delivery network or we also call it as content distribution network, its basically a large distributed system of servers which deployed in multiple data centers across the internet.

    Goal of CDN:

    1. Serve content to end-users with high availability.
    2. High-Performance.

    Below is a 3 popular jquery CDN:

    1. Google.

    2. Microsoft.

    3. jQuery.

    Advantages of using CDN.

    1. It reduces the load from your server.

    2. It saves bandwidth.

    3. The most important benefit is that it will be cached (if the user has visited any site which is using jQuery framework from any of these CDN).

    Below is the code to load jQuery from all 3 CDNs.

    Code to load jQuery Framework from Google CDN

    <script type="text/javascript"
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
    </script>
    

    Code to load jQuery Framework from Microsoft CDN

    <script type="text/javascript"
        src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js">
    </script>
    

    Code to load jQuery Framework from jQuery Site

    <script type="text/javascript"
        src="http://code.jquery.com/jquery-1.9.1.min.js">
    </script>
    

    Always using CDN is a good approach but sometimes case might found when the CDN is down then we will load jquery locally.

    The jQuery code below will checks whether jQuery is loaded thorugh Google CDN, if it found that the jQuery is not loaded fromGoogle CDN then it references the jQuery.js file from your folder.

    <script type="text/javascript" 
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
    </script>
    

    Firstly from Google CDN it will loads the jQuery after then it will check the jQuery object. If it's found that jQuery is not loaded successfully it will references the jQuery.js file from hard drive location.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: