XOR Media

Scheme Relative Urls

It’s been a busy few weeks for me at work, we launched our app, were featured in the iPad app store home page, and have been called out in other app store sections since. It’s been a wild ride, capped off by a trip to Comic-Con where I spent 5-6 hours a day on my feet giving my spiel about our app and company. Our booth was pretty sweet, definitely the best in the area we were in, and it was capped off with a really cool iPad video wall we built. The wall was a great conversation piece and drew a lot of attention.

So that’s why there hasn’t been an update here for a bit, but don’t get too excited as I don’t have anything substantial ready just yet, but I would like to provide a quick tip about Scheme relative URLs.

Scheme relative URLS are handy. They allow you to specify an external resource on another domain name without hard-coding the scheme used to get at it, normally http or https. When would you want to do that? The most common case is when a page will be viewed at times with http and others with https. It prevents requesting the resource with a mis-matching scheme causing warnings or even error messages in older browsers (IE.)

To use a scheme relative URL you just drop the first part of the url. It’ll look something like this.

<img src="//www.google.com/images/srpr/logo3w.png'>

Now when the page is loaded by a browser the image will be requested using whatever scheme is in use for the page itself. You can do this for css, javascript, or just about anywhere else you’d find yourself writing out a url.