Neither HTTP nor HTTPS

I don’t know if you caught this in the jQuery CDN post of earlier this week, but the link to jQuery didn’t use “http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min” or “https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min”, but “//ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min”.  Why is that?

I’m not sure when it became kosher by the browsers, but it’s called a protocol-relative URL.  If you make sites that serve pages up over http and https, then you’ve seen the need for this: to avoid a nasty (IE-only) security warning, you have to serve up assets that match the page.

Leaving the scheme off puts the browser in charge of asking for the assets the way that matches.  Problem solved.

Mostly.  Apparently, this had weird side effects in IE7 and IE8.

Advertisements