Today I Learned

A Hashrocket project

Protocol-relative URLs are now discouraged

For a long time, I’ve used protocol-relative URLs as a way to serve assets from a page using the same protocol (i.e. http or https) as the parent page. They look like this:

<img src="//google.com/path/to/image.jpg"/>

But now that SSL is encouraged everywhere on the web, one should always use https when an asset supports it.

<img src="https://google.com/path/to/image.jpg"/>

According to Paul Irish, It’s always safe to request HTTPS assets even if your site is on HTTP, however the reverse is not true.