There are practical differences in different URL types?
The other answers are very good.
I can only agree that any difference in efficiency compared to the bandwidth used (amount of bytes transferred) or performance will be minimal.
However, in terms of portability (see standard ISO 9126 Software Quality), I believe that systems should use whenever possible Urls related to the site root to access its own resources (images, styles, scripts, etc.) and always avoid the protocol for external resources.
The aspect that I consider most important is to maintain a pattern in Urls and a pattern only exists if all Urls start with the meso prefix. This helps keep developers sane and eliminates a lot of confusion, such as having to keep calculating directories mentally.
Your application is prepared to be safe?
Using completely absolute paths can create serious problems on websites that use HTTPS. The problem starts when your site is accessed via HTTPS (half secure) and tries to include a resource HTTP (unsafe).
For example, let’s assume you want to include the jQuery of a CDN:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
However, if your website is accessed via HTTPS, browser will complain of unsafe resource (HTTP) and will not load the script. As a result, Google itself indicates the most appropriate form:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Note: second this link, Internet Explorer in versions 7 and 8 will download twice if you include a CSS with a protocol-free URL, but I didn’t run the test.
A perfectly viable alternative is to always include external resources using HTTP
.
A personal experience
Regardless of approach, not everything is flowers.
Some time ago I made a system using a Java framework that generated Urls concerning the root of the server, for example:
/application/style.css
However, when the application was installed in production problems occurred as the company’s subsidiaries used it under a reverse proxy and the path to the root would have to be like this:
/web/application/style.css
The solution would simply add the way /web
Urls generated by the framework? No, because the company headquarters accessed the system directly, without going through the reverse proxy. That is, the application met two types of different origins that accessed it by different Urls.
A possible solution would be to identify the source of the request or still look at the URL of the request and dynamically change the root of the generated Urls, but in that situation was much simpler and direct to use paths related to pages:
../css style.
This was possible because I developed the system so that all pages were on the same level: /home
, /usuarios
, /clientes
, etc..
But even if the system wasn’t like this, I could add the relative path programmatically, exactly the same way frameworks normally do by adding a base path to all Urls, it’s not even?
${basePath}/style.css
Here basePath
can be both the path relative to the site root and the path from the current page to the base folder where the style is.
I’d say the three cases you mentioned are far more important than saving a few lousy bytes. ;)
– elias