Hacker News new | ask | show | jobs
by antris 4617 days ago
> if you’re writing CSS professionally then there’s really no good excuse for not using a CSS preprocessor.

CSS preprocessors aren't without their own problems as well. An app that I'm currently working on has a history of semantic HTML, but having no room for compromise had resulted in a CSS file that is 4000 lines long.

There were lots of cases where an innocent looking @extend created monster selectors (https://twitter.com/mezzoblue/status/390274599167877120/phot...). This is non-obvious behaviour that should be avoided.

1 comments

> This is non-obvious behaviour that should be avoided.

Generating selectors automatically obviously carries the risk of creating something excessively large that you don't want. But I want to challenge the widely-held view that a long CSS file is necessarily bad. First of all, what does 4,000 lines mean in terms of actual document weight? And what is the weight of the gzipped file actually served? Repetition in selectors might look bad on the surface, but this is exactly the kind of thing that compresses well. Once actually served this file then ought to be cached well, and so the issue of document weight is potentially moot.

Obviously there are extremes beyond which it may no longer be sensible to serve something like this, but arguably at that point you ought to be noticing issues in your un-preprocessed source anyway.