title: Why use protocol-relative URLs at all?
body: <p>It's been an oft-discussed question on StackOverflow what this means:</p>
  
  <pre><code> &lt;script src="//cdn.example.com/somewhere/something.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>This gives the advantage that if you're accessing it over HTTPS, you get HTTPS automatically, instead of that scary "Insecure elements on this page" warning.</p>
  
  <p>But why use protocol-relative URLs at all? Why not simply use HTTPS always in CDN URLs? After all, an HTTP page has no reason to complain if you decide to load some parts of it over HTTPS.</p>
  
  <p>(This is more specifically for CDNs; almost all CDNs have HTTPS capability. Whereas, your own server may not necessarily have HTTPS.)</p>