SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using the full url of your site in file paths to pages on your site.

    Hi,

    I was just wondering if using something like:

    <a href="http://www.domainnamewithcontent.com/games/1.html">test</a> rather than using <a href="games/1.html">test</a> will descrease any performance on your site.

    Does it slow down the loading of pages.

    Also what about when getting about 20 images for the page using <img src="http://www.domainnamewithcontent.com/image/img1.jpg" /> instead of <img src="image/img1.jpg" />

    Will all this slow down the loading of a page or add to the server load.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,274
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    performance difference will be so small as to be unmeasurable

    however, consider the inflexibility -- what if you change the path? you will have to edit all your pages

    use "root relative" paths (that start with a slash)

    thus, change this --
    <a href="http://www.domainnamewithcontent.com/games/1.html">test</a>

    to this -- <a href="/games/1.html">test</a>

    but not this --<a href="games/1.html">test</a>

    see the difference?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Doesn't effect page loading one bit.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Wizard trampt's Avatar
    Join Date
    Jan 2003
    Location
    Newport, RI
    Posts
    1,997
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth
    Doesn't effect page loading one bit.
    It does a lot if you are yahoo. The extra 1KB saved for shortening all the links on the front page, time millions & millions of page views daily .... it definitely adds up.

    For a small/medium personal or business site ... no difference.

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's wrong with using that in your quote then?

    Quote Originally Posted by r937

    but not this --<a href="games/1.html">test</a>

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,274
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    this -- <a href="games/1.html">test</a> -- is relative to the folder that the file it is in which contains this link

    this -- <a href="/games/1.html">test</a> -- is relative to the root folder of the site, and will work no matter which level of folder it's in
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So if I am getting it right, you mean that if I have a url http://www.domainname.com/games/games2/games3/1.html

    and I then wanted to link to a image that is located in the images file in the same folder as what the games folder is in then all I do is use:

    <img src="/image/image1.jpg" />

    and I don't have to use

    <img src="../../../image/image1.jpg" />





    Quote Originally Posted by r937
    this -- <a href="games/1.html">test</a> -- is relative to the folder that the file it is in which contains this link

    this -- <a href="/games/1.html">test</a> -- is relative to the root folder of the site, and will work no matter which level of folder it's in

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have just tested it and it does mean that. I had never new that. It just shows that there is still things to learn about html even though you think you know most of it.

    Doing /image/image1.jpg is much easier than trying to work out how many ../../../../ to put in when you have a long url that has many folders.

    Great stuff.

    Thanks!

  9. #9
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Location
    Dublin, NH
    Posts
    901
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See, negative linking or rooting to me is bad practice, because it quite often precludes local testing... It's why my website designs are all laid out cascading downwards from the HTML/CSS.

    HTML/CSS
    +----images
    +----scripts
    +----inlines

    so in that case my images would be in images/ and not /images/, since I cannot/willnot guarantee that my website is necessarily going to be in the root of the local drive/url/what have you.

    unless of course, the site has php theming, then my structure is
    HTML (and page specific CSS)
    +--- common images
    +--- themes (CSS)
    ____+--- style images
    +--- scripts

    In that case, images that get called from the stylesheet go in style_images/, while images that get called from the html go in common images/

    I won't even use negative paths (../) because that's the same as 'cross-linking' in programming, and from a programmers standpoint that's just bad form. (The term 'spagetti code' comes to mind)

    You make everything cascade downward it's just a HELL of a lot less headaches. If it warrants a subdirectory, place that subdirectory UNDER where it's being called from, and you are truly portable.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •