Protocol-relative Javascript URL

Archived from the Transloadit support forum. Originally posted on January 13, 2011; details may be outdated, see our docs for current behavior. Original thread

In your jQuery documentation, you present some JavaScript intended to select automatically between HTTP and HTTPS based upon the browser’s current protocol. This is much, much easier to do by simply using a protocol-relative URL. They’re obscure (and gaining popularity), but universally supported.

You provide:

var tlProtocol = (('https:' == document.location.protocol) ? 'https://' : 'http://');
document.write(unescape("%3Cscript src='" + tlProtocol + "assets.transloadit.com/js/jquery.transloadit2.js' type='text/javascript'%3E%3C/script%3E"));

Easier (and better?) is:

<script src="//assets.transloadit.com/js/jquery.transloadit2.js"></script>

Closing this ticket after our discussion in Skype. Conclusion: We will investigate if this works cross-browser.

Alright, it seems that this is all cross-browser compatible.
After a final review within the team we’ll most likely implement it.

Thanks a lot for the heads up Stephen!

Awesome! Glad to hear it.