At least a dozen heavily trafficked sites use only //
instead of https://
or http://
when linking to a *.css file, *.js file and sometimes, even when linking to other resources like external links. It seems to me that both versions are correct, using only //
when linking to a script or style file. A relative URL without a scheme (http: or https:) is valid, per RFC 3986: “Uniform Resource Identifier (URI): Generic Syntax”, Section 4.2.
Sites like Youtube, Google, CNN, WordPress, TechCrunch, Twitter, Reddit use only // instead of http:// or https:// when linking to resource files or external links.
I can’t provide here the impact of excluding a few characters but, for heavily trafficked sites can make a difference I suppose eliminating the loading time and bandwidth.
1 2 3 4 5 6 7 8 |
<!-- css file --> <link rel="stylesheet" type="text/css" href="//www.example.com/style.css" media="all"> <!-- favicon --> <link rel='icon' href="//www.example.com/icon.png" sizes="256x256" type="image/png" /> <!-- JavaScript file --> <script type="text/javascript" src="//www.example.com/script.js"></script> <!-- image --> <img src="//cdn.example.com/image.jpg" /> |