SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    External CSS & Javascript files

    Well, I'm a noob and this is my first post and Hello to all!

    I'm using a customized blogger template for my blog (visit it here: cricketbash.
    I'm planning host CSS & Javascript parts of the template as externally linked files. (say on google's servers)..
    Does it improve performance in terms of load time, browser caching?
    Any ideas to tidy up the xml template code are welcome.. Thanks

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,590
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Hi cricketbash. Welcome to SitePoint.
    I'm planning host CSS & Javascript parts of the template as externally linked files. (say on google's servers).
    Hmm, that sounds like overkill to me. I've not heard of CSS hosted externally before. It can be handy to have something like a jQuery library linked through Google, because users may well have that cached from visiting other sites, but no one will have your personal CSS/JS files cached, so it won't make any difference on that score. I would think that managing the CSS/JS files would be more awkward if hosted at a different location from your other site files. Anyway, I'd be interested if anyone else thinks differently; but personally, I wouldn't do it.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Anything remotely hosted suffers two problems.

    1. It takes longer to load because of the extra domain lookup (unless your visitor already has it cached because it is shared between lots of sites - eg grabbing jQuery from Google).
    2. It means that the site will break if either of two servers is down instead of only one.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    Non-Member
    Join Date
    Sep 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I would have to say that externally hosting CSS is unnecessary. Just host it yourself. It's faster on load time, easier to edit and manage as well

  5. #5
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW! That's lightning fast replies.. Thanks very much, both Ralph & Steve(felgall).

    @Ralph: Well, I do agree that its a bit of an overkill for a blog and for a simple xml template. But people using external style sheets isn't uncommon.. In fact, it is used all the time for large sites, except for the fact that they combine CSS files into as few HTTP requests as possible to cut down on RTT(round trip times). Thanks for your time, however, I fully appreciate it..

    @Steve Chapman: WOW! I cudn't run into a better online guru than you.. Felgall, I'm humbled, Touchwood! (am I a flatterer?). But I understand that you are a About.com guide and I hold you in awe!

    Coming back to our thread, yep, I'm indeed aware of DNS look ups & RTT.
    I only opened this thread to know better about the "Browser caching" principle and how it enables us to cut down on load times. I read somewhere on the net that ppl online could be so impatient that they leave your site if it doesn't load within 7 secs.

    Secondly, I can compact CSS code and implement it inline, but I definitely appreciate your help on better load times with javascript. I mean, Do you ask me to combine all JS files for a single HTTP request ( and host them on code.google.com) or include all scripting inside the <head> tag??

    I really appreciate and look forward to your reply. Thanks Steve, Your fan base has now gone up by 1 more..

    and yes, how did you like my cricket blog( I still have to do heck lotta work on it though)? Do you like cricket?

    Until next time.. Cheers!

  6. #6
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    You'd keep the CSS external away from the markup instead of inline. If inline it would just add the individual page weights and slow rendering (also maybe a bigger maintenance issue) and wouldn't really be cached if were within the markup. Since each page would have to fully load first if it contained the CSS instead of a linking to a common CSS file.

    The issue with the JS was, if it's an extremely famous online library used by tens of thousands of websites. Then the probability of a user already having download the script from a specific URI are higher like Ralph mentioned. Else it might be better writing or hosting your own.

  7. #7
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If inline it would just add the individual page weights and slow rendering (also maybe a bigger maintenance issue) and wouldn't really be cached if were within the markup.
    Thanks Xhtmlcoder for your reply..
    But boy, isn't it getting hotter? Well, Two contrasting views there.. Individual page rendering vs Browser caching.. which is faster?

    Xhtmlcoder makes a valid point, as CSS is not cached and every subsequent page has to be rendered individually..

    That's the reason why I landed here, but I'm clueless and confused on which school of thought to follow..I couldn't figure out the relative advantages of both methods and am desperate to seek a clarification..

    Waitin' for felgall..

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,590
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    There are two issues here: 1) whether or not your CSS should be hosted externally, and 2) whether to put your CSS styles inline or not. Point 1) is perhaps debatable, but regarding point 2), using inline styles is absolute madness, so just don't do it. It destroys the whole point of CSS—which is the ability to change site-wide styles from a single location. (To update inline styles you'd have to open every page in the site separately and modify the those styles over and over again, which is untenable.)

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    What you should be doing with the CSS is placing it in external files that are hosted on the same server as the rest of the site. That way you get all the benefits - caching between pages, only one copy to change etc - without the overheads of having to look up a different server and having the page layout break if that other server goes down.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •