-2

CSS rules can be easily compressed:

.rule
{
    background-color: red;
}

to

.rule{background-color:red;}

to save up traffic. (remove spaces, tabs, newlines). But is it worth? Browsers can parse the files more quickly, or harder? What about google, SEO? Will they like it too? Any experiences?

John Smith
  • 6,129
  • 12
  • 68
  • 123
  • 1
    This has to be a duplicate. – Xareyo Feb 21 '14 at 10:57
  • 1
    removing whitespace doesn't affect your browser's time of handling the data. it only affects the bandwidth and download time of your assets. Maybe you're confusing removing whitespace with compressing or minifying\. – yoavmatchulsky Feb 21 '14 at 10:59
  • 2
    It's always good to make your production ready files as small as possible. But for that you should not try to write all your CSS in just one line, since that would be a pain. There are CSS preprocessors (keywords: compass, sass, less). Which these you can have working copies of your CSS (with a clean formatting) and these will be automatically compressed in one .css for production use. – Nico O Feb 21 '14 at 11:06
  • 2
    Minifying is best practice. In a .NET environment I have it combine and minify all CSS in release but keep them expanded and separate in debug. Outside of .NET, I adjust my SASS settings to change the output style when I am ready to release. – Alan Shortis Feb 21 '14 at 11:06
  • This question appears to be off-topic because it is about SEO and seeking experiences – John Conde Feb 21 '14 at 12:53

2 Answers2

2

Well... even if the css isn't used (yet) for the ranking algo, the loading time of a webpage seems to be used in ranking algorythm.

Even if css files arn't the fatest files to load, every kb saved seems to be good.

By the way, you can use minifiers to do it for you (for css, js ...). In a long time strategy, it will be good, for sure. Even more if you'll catch lot of visitors.

1

But is it worth?

That's subjective.

Browsers can parse the files more quickly, or harder?

It makes no appreciable difference to parsing.

It does reduce the size of the file though, and that will allow it to be downloaded faster. In a large file or on a slow network connection, this can be quite significant.

What about google, SEO?

Search engine algorithms are secret, but they appear to pay little to no attention to stylesheets.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335