What is CDN for JQuery? If CDN will fail, how to handle JQuery file?

CDN is nothing but content delivery network. In this scenario, we will refer JQuery file which are hosted in the different sites.

Microsoft, Google and even JQuery site also providing JQuery file reference with different versions. So, people can save bandwidth and feel more reliability. Most of the people like to host in their website only. So, both the possibilities are important.

If content provider site is down(Google, Microsoft, JQuery and more), we can able to use local copy of jQuery file. for that one use below code.

CDN Advantages: Server Fast, Parallel Download, Reduce load of page, Caching.

Google server

//google server
<script  type="text/javascript"

//you can use it to do async loads of jQuery, which is what you're referring to.

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript"><!--
google.load("jquery", "1.7.1");
google.setOnLoadCallback(function() {
// Place init code here instead of $(document).ready()
// -->

Jquery server

<script type="text/javascript"

Microsoft server

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

If any file is missed , our local copy will save in the production environment.

<script type="text/javascript">
if (typeof jQuery == 'undefined') {//if file not found.we will take local copy of JQuery
    document.write(unescape("%3Cscript src='/js/jquery-1.4.2.min.js' type='text/javascript'%3E%3C/script%3E"));

see more JQuery Interview Questions
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar