views:

123

answers:

2

I have a situation where it looks like the easiest solution would be to convert from using relative to absolute paths for included files such as CSS & Javascript. There are around 10 included files in total per page - pretty much the same 10 on most pages.

I'm wondering if there would be any significant overhead (or indeed downside, other than portability) in doing so? This is a LAMP setup on a dedicated sever where everything is running over https.

EDIT: To clarify, I mean going from "../foo.css" to "https://bar.com/foo.css".

+6  A: 

The only extra overhead is that they'll be slightly larger (hence making the page that contains them exactly that much larger). Unless you've got huge numbers of URLs per page, that difference should be negligible.

That said: when in doubt about performance the best thing to do is measure it.

Laurence Gonsalves
No server overhead at all? As in there's not a DNS lookup per file or similar?
da5id
You browser is going to convert relative URLs into absolute URLs before fetching them. There shouldn't be any extra DNS lookups (and DNS lookups should be cached in any case).
Laurence Gonsalves
That's what I was hoping. I'll leave the question open longer in case anyone has anything to add, but consider your answer provisionally accepted. Cheers :)
da5id
Just go ahead and accept his answer anyway. Browsers do tons of client-side optimizations, and relative vs absolute URLs is not going to affect that. As Laurence said, browsers already convert relative into absolute URLs when resolving them.
Kevin Ballard
+1  A: 

I don't think changing the paths from relative to absolute will have a major impact on performance.

My suggestion would be to try and group your CSS files together, into one CSS document, and likewise for the JS files.

That way your website performance would be optimised as you'll only make 2 HTTP Requests to the server (for CSS and JS files not inc. images and other elements you have on the page)(one for the CSS file and one fo the JS file) as opposed to the 10 you are currently making.

I can only think that the performance of the individual maintaining the site will be hindered: maintenance of absolute URLs is a pain compared to relative URLs

I just found this resource, and it seems that they haven't seen a performance impact of the two types of URLs: http://good.ly/wj3cfe

Lycana
+1 for good suggestions. Cheers :)
da5id