What is Content Delivery Network(CDN)? How do I get benefit out of it for JQuery?

0 votes
asked Jun 16, 2013 in JQuery by anonymous

When I was discussion with one of my friend he suggested me to use Content Delivery Network(CDN) for linking JQuery into my website to speed up the performance. What is that CDN? How could that improves my page performance?

Share

1 Answer

+1 vote
answered Jun 17, 2013 by Aadhira (1,213 points)
selected Jun 18, 2013 by administrator
 
Best answer

Content Delivery Network (CDN) is nothing but set of servers located in different geo graphical location around the word. The purpose of this CDN is to provide the customer required service as quick as possible also to make sure, the customers receive the services without any break downs. So, for example, if a service is deployed in Europe and if that service is down, then it will automatically send the request to the next available location to get it processed.

There are different companies maintain CDN around the world including Microsof and Google. They also have JQuery Library available on their servers so that it can be downloaded in to the client machine whoever located neared to server location.

You can also use also use those JQuery Library Script link added on your web page and let your clients get downloaded JQuery from those server. There are advantage as well as disadvantage.

http://www.asp.net/ajaxlibrary/cdn.ashx

https://developers.google.com/speed/libraries/devguide#jquery

The advantages are:
1. JQuery script file download will be fast becaus they do not need to hit your server everytime.
2. If multiple websites are using the same CDN, then if the client used any one of the website, which uses the same CDN, before visiting your web site, then the JQuery library will be in the client machine's Cache already. So, the client's machine does not need to download once again. So, your web page performace will be fast because there is no down load time.

But the disadvantage would be,
You need to be dependent on that CDN service. If that is down for some reason, your website may not work the way it suppose to work.

You can even avoid this one by implementing the below sort of code. Below sample given in microsoft website itself.

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
To allow your page to fallback to loading jQuery from a local path on your own website if the CDN happens to be unavailable, add the following element immediately after the element referencing the CDN:
<script>
        // Fallback to loading jQuery from a local path if the CDN is unavailable
        (window.jQuery || document.write('<script src="/scripts/jquery-1.9.0.min.js"><\/script>'));
</script>

Your answer

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015 pinfaq.com
...