Is there a benefit to NOT using a public CDN to load Javascript libraries?

Assuming he's talking about professionally hosted CDNs like Google, then the best bet is to do this:

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write("<script src='js/libs/jquery-1.5.1.min.js'>\x3C/script>")</script>

(taken from http://html5boilerplate.com/)

That way, you get all the benefits, without the risk of your website breaking if Google's CDN goes down.

But, he said:

USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO NOT CONTROL.

I don't actually think he's talking about CDNs. I think he's just saying "don't hotlink scripts from random websites".

You wouldn't want to do this because the website might change where the script is located, or even change the script. A CDN would never do this.


Basically, it's a matter of trust. You need to trust the host to not change anything in the hosted file and you need to trust in the availability of the file. Can you be absolutely sure that the URL will not change? Are you comfortable with the fact that any downtime of their servers results in downtime of your application?