The idea of browsers supporting protocol relative URLs (e.g. <img src="//domain.com/img/logo.png">) is intriguing for linking to an external assets like JS and images when a site could be optionally loaded in an SSL or clear-text session. I wanted to test a wide variety of browsers for support of this method and any impact on load times this might have in comparison to traditional methods of client-side solutions.
Google Analytics handles this via a JS ternary test:
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'
or as I have in the past:
This topic has been discussed at length by Paul Irish: http://paulirish.com/2010/the-protocol-relative-url/
and the creator of jsperf, Mathias Bynens: http://mathiasbynens.be/notes/async-analytics-snippet
I am going to test loading a JS & IMG files via various methods and test for their success.
Ready to run.
|Direct Link Control
|Protocol Relative Test
You can edit these tests or add more tests to this page by appending /edit to the URL.