Have you ever seen a url that looks like this?
- <img src=’//fast.cdn.net/pix/smiley.jpg’ />
We’ve also created links that started from the first slash and dropped the domain, but I’ve never seen links that dropped the http or the https from the link. Ned explains the benefits of this technique thusly:
Here, we’ve left off the protocol scheme, but included a host name. In this case, the protocol scheme from the displayed page will be used, but against the host in the URL. The relative URL system is still in play here: omitted portions of the URL at the beginning are taken from the base page, and the relative URL takes over whereever it starts. On an HTTPS page, this will be an HTTPS request to the CDN, on an HTTP page, it will be an HTTP request.
I love it when I learn something new about a piece of technology I’ve taken for granted for years.