PDA

View Full Version : Linking with full website address in HTML...


Morgoth
05-10-2003, 04:47 AM
This is a question I was thinking about a long time ago, but was only remembered of it now...

If I add an image on my html page like so:
<img src="http://www.Host.com/Username/Images/Picture.jpg">
Does it take up any more bandwidth, or take longer to load, or anything different or added, or changed or anything at all, than if I did it this way:
<img src="Images/Picture.jpg">

It's not been haunting me or anything, but it's made me think, and it's made my wonder...

There is also, the method:
<img src="/Username/Images/Picture.jpg">

Which, when that first Forward Slash ("/") is added, it will drop from from what ever folder it is in now to find the folder I want... Oh, and also:
<img src=".../Images/Picture.jpg">
(Which is not directly related the first link I gave out.)

So... Anyone know if it effects load time or something?

ionsurge
05-10-2003, 12:55 PM
Quick and simply no to the taking longer to load, it shouldn't be noticeably different. The main factor is when you use a fixed path, instead of a relative path, it will just take a little longer to actually check if the site/image exists, but it ought to be only a few fractions of a second even on a 56k.

Relative linking will save you a little data transfer but nothing very big to be honest.


Mind you relative linking (ie "/images") will help you transfer your data from offline and online use - or to another website with ease.

Morgoth
05-10-2003, 05:47 PM
That's what I figured...
Anyone else wanna add their thoughts?

brothercake
05-10-2003, 06:13 PM
I agree - between "/images/" and "../images" there's no noticeable difference, but with "http://..." there would be, because it has to go outside and back in again.

The base-relative "/" approach is best I think, for ease of moving sites between hosts or re-arranging them - you could move a page to a deeper nested folder and its links won't all break.

liorean
05-10-2003, 07:04 PM
Well, there is some difference between root relative (/directory) and relative(../directory) in the sense that root relative is always going from the host domain. For example, when I was hosted on http://members.evolt.org/liorean/, a root relative link would end up at http://members.evolt.org/, not my own top directory.

As for the requests, IIRC, all requests are sent from the browser using a root relative path and a host. Proxies can send an absolute URI without a host instead. This means that all URIs have to be resolved on the client side, and then sent in the same format, so there is no difference serverside. Generally the resolving of a URI doesn't take any noticable time.

Morgoth
05-10-2003, 07:44 PM
These are all great points.