Why do sites place all css onto a single line?

Discussion in 'CSS' started by goalie35, Oct 14, 2010.

  1. #1
    I've checked out the css files of some of the largest websites on the web today and one thing I've noticed is they seem to place all of their css onto a single, extremely long long.

    This one line is dificult to browse through (due to my computer scolling slowly due to the size of the line) and impossible to read cleanly.

    So my question is, why do websites place all css code onto a single line? What's the advantage of that over writing a cleaner,multililne approach?

    Thanks.
     
    goalie35, Oct 14, 2010 IP
  2. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It could either be a personal choice, or because they want to keep things optimized. The more lines you use, the larger the file size, and thus the longer it will take to load the page, especially if you have a lot of css code.
     
    GWiz, Oct 14, 2010 IP
  3. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That is either call compression, minification, or optimization.
    It reduces the file size by removing all the formatting, and that reduces bandwidth and loading times, but it's only worth doing on high traffic sites.
    There are websites that compress files, like Yahoo's YUI Compressor, and there are websites that uncompress them, like MAB Blog's CSS Uncompresor
     
    Cash Nebula, Oct 15, 2010 IP
  4. ralphnsk

    ralphnsk Member

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    I bet they do it so it would be more difficult for other webmasters to actually read CSS code and steal parts of it, lol.
     
    ralphnsk, Oct 28, 2010 IP
  5. WuLF

    WuLF Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Probably a combination of both :p
    But if that's the case its easily combated with firebug xD
     
    WuLF, Oct 28, 2010 IP
  6. TheDataPlanet.com

    TheDataPlanet.com Well-Known Member

    Messages:
    503
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #6
    Not only CSS but they are putting HTML as well as JavaScript on a single line as well. It's done automatically by their editor programs that compresses the downloading bandwidth and time for their users significantly for better user experience.

    When they need to edit it again, the code will be all expanded to normal coding alignment.
     
    TheDataPlanet.com, Oct 28, 2010 IP