Speed comparison - absolute vs relative path links

by Jacob Pie   Last Updated July 31, 2016 08:03 AM

Let's say I want to link to a parent directory (http://example.com/library/) from a subdirectory (http://example.com/library/html/basics/).

The link to the parent directory can be:

  • href="../../"
  • href="/library/"
  • href="http://example.com/library/"

Is there a speed difference based on which way I write the link? I'm not asking about the website loading speed, but if there is a noticeable difference while traversing to the directory.



Answers 2


HTML/CSS relative based paths will always be faster for server speed, this is because the server has less code to send. Relative paths in HTML or CSS form are translated by the end-user's browser and not the server.

So technically, its faster for the server and slower for the end-user, but the end-user would never notice the difference, since the processing required is less than nano-seconds, therefore end users are far more likely to see the difference from relative because the server is going to be able to serve them better.

Simon Hayter
Simon Hayter
July 30, 2016 17:55 PM

Effect for browser:

Though this looks like a bit of work for web browser, but technically it does not make much of a difference. The browsers are too fast to handle these relative url structure and make a call to application server

Effect for application Server:

None, as it needs to return the requested file (relative/absolute link ultimately maps to a web path)

Effect on page size:

Yes there would be some reduction in size (again not something that would make a huge difference to your page's performance that could be achieved by something like content encoding gzip or minifying resource)

So i think technically the absolute/relative urls dont make much of a difference on page speed / any weightable matrix.

Yes it make huge difference in managing multiple environments like dev, pp, prodpp etc

Example : on your local development you might have dev.example.com on pre production you might have : pp.example.com . .

So in those scenarios it would be relatively easy to manage code with relative urls (though can be managed by environment settings also)

abhinsit
abhinsit
July 30, 2016 18:32 PM

Related Questions


Is it bad to link internal URL with http?

Updated April 21, 2016 08:01 AM

Absolute vs Relative url

Updated May 12, 2016 08:01 AM

Schemaless URLs in canonical tags

Updated July 25, 2016 08:01 AM

.htaccess rewrite URL leads to missing CSS

Updated March 29, 2017 18:04 PM

Absolute or relative local URL in Schema.org JSON-LD?

Updated September 24, 2016 09:01 AM