I was reading an article about why relatives URLs should be avoided for web developers ( http://yoast.com/relative-urls-issues ), but what about for things like ajax calls to scripts that are stored somewhere in the same directory hierarchy?
One of the points on why relative URL’s are “still being used” is that
Relative URLs are often used because developers have a test environment on another
hostname and it makes it easy for them to move stuff between their test environment and
their live environment. Other reasons include that it’s “just easier in website
maintenance”. They’re also, in my opinion falsely, promoted by some websites about site
speed because they’re “shorter” and thus “faster”.
Which is mainly the reason why I am using them as well: having to go through every script carefully replacing all URL’s if I decide to move my application somewhere else seems very error-prone.
To avoid a discussion topic, how can I effectively avoid relative links when I have possibly dozens of relative links spread across multiiple js and php files?
That link 404’d on me, but i’d imagine the only thing that would make it “faster” would be that there is no need for a DNS lookup when using relative.
And it’s true, moving from dev, to qa, to prod is easier when using a /contextroot/webservices-location?query formatted url.
When it doubt, use firebug to profile your scripts if you’re concerned about performance and the server’s reponse time in resolving DNS in your local or external calls.
Just my two cents.