I just found out about this incredibly useful trick for loading absolute resources with either http: or https: depending on the protocol with which your page was loaded (to avoid those "mixed content" complaints from browsers).
Amazingly, you can just leave the scheme (protocol) part off the URL entirely. So for instance, if you're loading jQuery from the Google CDN with this path:
you can load it like this instead:
If the page that's in is served via http, that path will become
http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.jsIf it's https, that will become
https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.jsE.g., it's a path relative to the protocol (scheme) but in all other ways absolute.
(Naturally, if you load a file via the file: protocol — e.g., locally — it will try to resolve that locally and blow up. But you don't do that, do you?)
And you thought you knew all there was to know about URIs...