using full links or relative links

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mccommunity
Forum Commoner
Posts: 62
Joined: Mon Oct 07, 2002 8:55 am

using full links or relative links

Post by mccommunity »

we are building a website is there truth that it slows the process down if you use http://websitename.com/pages/link.php rather than pages/link.php . I am not sure what is best. Could someone help me with this one and let me know why? Thanks.


Mark
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Well, by using

Code: Select all

<a href="http://websitename.com/pages/test.html">
Would make the HTML file larger in size which could slow down the page load time.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

not sure how browsers work, but im assuming after it connects to the main server, loading directorys under it would take less time.

I've always used relative, cept for things, like includes, that go on every page (in different directorys), because you'd need absolute for them. and of course, other people's sites.
User avatar
rprins
Forum Commoner
Posts: 31
Joined: Sat Jun 21, 2003 5:46 pm

Post by rprins »

If you ever need to change URLs (http://www.xxx.com becomes http://www.yyy.com), your static links will all break. Personally, I use dynamic linking (./page.html or ../mydir/mypage.php). This way, I can just move my directory tree around and there are no problems if I change the URL name. The only time I use static links are when I have subdomains and I need to get to a different part of a site (admin.site.com to site.com).

Hope that helps.
User avatar
cybaf
Forum Commoner
Posts: 89
Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden

Post by cybaf »

The main reason for using relative links (as I've learned anyways) is to hide the document root. Depending on how your webserver is setup this is important. Because in many cases the relative link dir/link.php points to a different place compared to http://somesite.com/dir/link.php...
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

There aren't many good reasons to use absolute paths that I'm aware of.

"/" is always your document root, everything else can be defined in your server settings... that should handle 95% of it.
Post Reply