My site loads external javascript with relative protocol, i.e.
<script type="text/javascript" src="//somewhere.com/script.js"></script>
(Note: the script tag is injected asynchronously to fetch the script after page load.)
but my dns-prefetch tag is absolute protocol, i.e.
<link rel="dns-prefetch" href="http://somewhere.com/script.js">
so when the site is loaded over HTTPS the prefetch is http and the script is https. There is no warning in the Chrome console about this.
Besides keeping these consistent, is there any performance benefit to changing the dns prefetch link to relative protocol?
One thought I had was that because all dns prefetch supposedly does is resolve an IP from a hostname, it might actually be beneficial to use http in the prefetch to avoid needing to do the SSL handshake. But this assumes the dns-prefetch link instructs the browser to make a network request, which I'm not sure is what's happening.
The following three lines, when supported by the browser, do the same:
<link rel="dns-prefetch" href="http://SERVERNAME/some.script.js">
<link rel="dns-prefetch" href="https://SERVERNAME/some.script.js">
<link rel="dns-prefetch" href="//SERVERNAME/some.script.js">
They all try to request A and AAAA resource records from the DNS resolver, if such information is not already present in the browser name service cache.
Therefore, the performances are the same.