Allow me to direct you to exactly what you are seeking. The information you are looking for is within an RFC document, so there may be some extraneous details to sift through before finding what you need. However, this method is a legitimate feature (not a workaround) commonly used by supposed http clients.
b) If the embedded URL begins with a scheme name, it is interpreted as an absolute URL and the search ends here.
c) If the embedded URL does not start with a scheme name, it takes on the scheme of the base URL.
To explore further: (look for the section "Resolving Relative URLs" and refer to steps 1 and 2 below). Alternatively, visit:
A little note: I implement this method in most of my projects, not only for JavaScript resources but also for linking to images and CSS files (UPDATED: excluding stylesheets).
This approach works universally. I have tested it in various browsers like IE, Firefox, Opera, Chrome, Safari/Webkit, including earlier versions where applicable.
Here are a few examples:
- < img src="//static.example.com/img/token.png" />
- < script type="text/javascript" src="//static.example.com/js/jquery.js">
I prefer using this technique over writing code to determine whether we are on http or https.
The only exception is avoiding its use for stylesheets.
While the following method is valid and functional:
- < link rel="stylesheet" type="text/css" href="//static.example.com/css/screen.css" media="screen" />
In Internet Explorer, this will result in two HTTP requests. This issue affects IE7, IE8, and early versions of IE9.
In essence, scheme relative URIs can and should be utilized for all resources except stylesheets.