Hacker News new | ask | show | jobs
by kapowaz 4904 days ago
> One functionality of CSS often abused without awareness are selectors [...] How elements are selected within CSS affects performance, including how fast a page renders

This assertion used to be thrown around as one of the supporting arguments for using OOCSS, but I'm sure I later read that it was largely debunked; the performance implications were negligible and so it was just making CSS less legible/maintainable for no real reward. Has that changed? Have you any recent benchmarks to share?

4 comments

My understanding is that performance is a negligible factor next to maintainability when writing CSS in virtually all cases. The best post I've seen on the subject is by Steve Souders[0], which does include some numbers.

[0] http://www.stevesouders.com/blog/2009/03/10/performance-impa...

Further reading:

http://csswizardry.com/2011/09/writing-efficient-css-selecto... https://developer.mozilla.org/en-US/docs/CSS/Writing_Efficie...

>> This assertion used to be thrown around as one of the supporting arguments for using OOCSS.

I've never seen selector performance used as an argument for OOCSS.

>> ...and so it was just making CSS less legible/maintainable for no real reward.

That's a pretty broad sweeping statement that I think you'd be very hard pressed to back up. OOCSS is all about maintainability. Legibility is debatable, but I've seen OOCSS examples that are just as legible, if not more so, than old-school CSS (leaning more on tagname selectors/DOM structure - if that is the opposing stand-point, sometimes it's hard to tell what OOCSS dissenters are really arguing against).

> I've never seen selector performance used as an argument for OOCSS.

Harry Roberts is one of the most vociferous proponents of OOCSS, and he has written about it a few times, notably here: http://csswizardry.com/2011/09/writing-efficient-css-selecto...

> That's a pretty broad sweeping statement that I think you'd be very hard pressed to back up.

I'll admit it's an opinionated statement, but I don't think that in itself makes it invalid. Opinions are certainly divided when it comes to how to structure CSS selectors, and I am firmly in the camp that OOCSS is bad stuff.

I've had a half-baked article on the whys of an alternative structure to OOCSS drafted for about 18 months now, so I guess it might be time to dust it down and fully write it up.

Here's an interesting presentation from GitHub on CSS performance: https://speakerdeck.com/jonrohan/githubs-css-performance
The only CSS performance issues I've seen are images causing scrolling not to be smooth.