Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2011
    Posts
    164
    Thanks
    7
    Thanked 0 Times in 0 Posts

    is this a bad idea ../../../myfile.gif

    Does it have a negative effect on speed loading on my website to have images or files like css coming from ../../filename.gif or is it better to more direct link?

    Thanks

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    Nope! not at all!

    Whether to use relative or absolute URLs depends on the needs:

    If the image always is located at the same directory relative to the document, then you can use ../../filename.gif.

    If the document is always located in the same postion, on the same server or computer you can use /images/filename.gif
    as there is no dots in front of the first slash, it means root-directory.

    But if the images is located on a different server, you need to use http://www.example.com/filename.gif

    There are cases where you can choose between all version.
    e.g. for files on the same server that never changes neither position nor relation

  • #3
    Regular Coder
    Join Date
    Mar 2011
    Posts
    164
    Thanks
    7
    Thanked 0 Times in 0 Posts
    thanks mate

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Using the absolute address is the one that can be less efficient - it can require a DNS lookup to locate the nameservers in order to do another lookup to determine the IP address to look up the hosting server in order to then do yet another lookup to find the folder that the domain points to.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Linking comes in multiple flavors: absolute, relative or web root (aka root-relative).
    http://www.motive.co.nz/glossary/linking.php

    If your image is being used by multiple pages from multiple directories, it may pay to use the web root.

    For instance, if you have a file '/images/flowers/sunflower-banner.gif' and it is used by
    files '/news/index.php', '/posts/2012/02/index.php' and '/bb/forum/index.php' in a footer or header, you would have to use three different addresses to display the sunflower-banner.gif: for news it would be '../images/flowers/sunflower-banner.gif', for posts, it would be '../../../images/flowers/sunflower-banner.gif' and for the forum it would be '../../images/flowers/sunflower-banner.gif'.

    It's easier to use the web root for all three in an included header or footer.
    '/images/flowers/sunflower-banner.gif'
    That way all of them will be able to reach the same image regardless of position in the directory structure of your site. Web root is always http://mysite.com/images/flowers/sunflower-banner.gif minus 'http://mysite.com'.


  •  

    Posting Permissions

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