4 ms·
The author recommends using protocol-less urls for content, but do they actually work in most browsers? Most js include this use js to determine the http vs htt
by rmc 16y ago
The author recommends using protocol-less urls for content, but do they actually work in most browsers? Most js include this use js to determine the http vs https part of the url. Google analytics does this.
- jmillikin 16y agoI used them for a short time on my site -- they work as expected in browsers, but some less-used agents (eg, iPhone feed readers) didn't know how to parse them. If you need to support every device, absolute URLs are the way to go.
- eli 16y agoI'm wary of using them myself, but note that Google is actually using a different hostname for HTTPS versus HTTP, so this isn't an option for them.
- Encosia 16y agoAs it turns out, Google does serve the script with SSL at https://www.google-analytics.com/ga.js https://www.google-analytics.com/ga.js if you request it. So, //www.google-analytics.com/ga.js works.
- CWIZO 16y agoInternet Explorer will download CSS files twice if served with the relative protocol "thingy": http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/ http://www.stevesouders.com/blog/2010/02/10/5a-missing-schem...
- Encosia 16y agoThey do work in every browser browser I've tested. It's worth noting that I did find a couple browsers that won't accept a protocol-less URL in the address field (iOS Safari being one), but those browsers did properly handle protocol-less script references in documents. So, it's easy to mistake those as browsers lacking support, but they actually do handle the protocol-less URLs correctly where it matters. I ran this simple HTML page through Browser Shots to test about as wide a variety of browsers as possible, quick and easy: <html> <head> <title>Testing protocol-less URL</title> </head> <body> <p>A message should hopefully appear below me...</p> </body> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> if (typeof jQuery !== 'undefined') { jQuery('body').append('<p>Protocol-less reference worked!</p>'); } </script> </html>
- Sephr 16y ago> I did find a couple browsers that won't accept a protocol-less URL in the address field Why would you expect them to accept that? The URIs aren't protocol-less, they have relative protocols, and there's nothing to relate the URI to.
- Encosia 16y agoI didn't know what to expect, which is why I was testing. All of the desktop browsers on my machine do resolve the protocol-less URL in the address field though (as HTTP). I mentioned it because I can see how it would be easy to notice that behavior on the desktop, see the same thing fail on an iPhone, and then assume that mobile Safari doesn't support these URLs at all.