I recently ran across a website that had some interesting styling on a select element. I went to investigate and found this (names changed to protect the innocent):
<script type="text/javascript" src="//www.domain.tld/file.js"></script>
It works despite HTTP: being omitted. What is the purpose of leaving off the protocol?
It will use the protocol you’re already using. Useful for sites with both
httpsandhttpversions.So if you’re on
https://www.domain.tld/file.jsthe script will behttps://www.domain.tld/file.js.If you’re on
http://www.domain.tld/the script will behttp://www.domain.tld/file.js.