Referencing External Script Libraries

Google’s CDN is a very powerful way of accessing JavaScript libraries like jQuery, Mootools etc. This is a great article on why you should be using a CDN for this accessing these kind of libraries:3 reasons why you should let Google host jQuery for you . The one problem is dealing with them when your page is accessed via https and the “mixed content” warning the browser can throw.

Fortunately there is a very simple solution:

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

Notice the complete lack of http or https, this is not a typo, it basically retrieves the script using the protocol the page was called with! This works particularly well in template scenarios like master pages.

One Response to Referencing External Script Libraries