What's the Protocol?

On a recent project, @austegard recommended I look into using protocol-less URLs to load jQuery. My initial reaction was that of ignorance - “what is a protocol-less URL?” I quickly found an example:


When I saw it, I thought, “That doesn’t look right. It won’t work.” But I was wrong. Sure, it’s missing an ‘http:’ or ‘https:’ prefix, but it works just fine. Look at the source for this page, and you’ll see that there is no ‘http’ or ‘https’ in the link above. But if you click on it, it loads jQuery without any trouble.

Is this the best way?

Protocolless URLs are interesting, but what’s the point? And what are the other options?

Suppose you have a website, such as contoso.com, and your website is available on both HTTP and HTTPS - at http://www.contoso.com and https://www.contoso.com. Next, suppose you want to load a javascript library from a different server, such as loading jQuery from the CDN link above on the ajax.googleapis.com server.

How can you add a script tag that loads jQuery?

Read More