SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Linking external styleshheet and javascript the right way?

    Hi,

    maybe its a stupid question and its something i just realized when i was surfing around. Don't know what others do, but i have the bad habit to look into source codes while surfing the web

    What i see is that for example all WP sites have the full url to stylesheets in the head: http :// www. blablub. com/theme/css.css

    Does it make a difference if there is just: /theme/css.css

    I mean does it not take an extra dns lookup if i put the full url in?

  2. #2
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,828
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    The only difference in terms of overhead if you put the full URL or a short one is the extra bandwidth taken to transmit the domain name, and those few bytes are going to make absolutely no difference. The parsing is all done by the browser before it sends a request. (You can tell this by writing a page with internal links given by both full and short URLs. Hover your mouse over them in turn - you'll see that in both cases, the link destination is the full URL)

    One advantage of just using the short form of the URL (either relative or root reference) is that it makes your code more portable – you can move it to another site without having to rewrite all the links. On the other hand, if you use the full URL (absolute reference), anyone downloading your page onto their computer (do people still do that, in these days of broadband?) will still get the stylesheet regardless of what option they save it with.

    I tend to just use the relative/root reference, but that's because it's less to type, and I'm lazy

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevie D View Post
    One advantage of just using the short form of the URL (either relative or root reference) is that it makes your code more portable
    Sure, but this is just a question on static pages. In php or a cms you set it in one place. So if you move your cms you change the settings and its done.


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
  •