Jens Meiert

Performance of CSS Selectors is Irrelevant

Jens O. Meiert, March 12, 2009.

This entry is filed under .

… if you like to have a “black or white” interpretation of Steve Souders’ recent research. Currently we’ve still got few yet a few more numbers than before backing up what we always suspected, that merely optimizing selectors is kind of micro-optimization, micro-optimization that might for example just mean microseconds saved when avoiding the universal selector.

Based on these tests I have the following hypothesis: For most web sites, the possible performance gains from optimizing CSS selectors will be small, and are not worth the costs. There are some types of CSS rules and interactions with JavaScript that can make a page noticeably slower. This is where the focus should be.

I’d welcome everyone interested in CSS development and performance to read Steve’s article, have a close, absorbing look at the following chart, and to memorize what is following after the following (that just said for the people who have a fetish for English rhetoric by Germans):

Internet Explorer 7, page render time, number of CSS rules.

Figure: Copyright 2009 Steve Souders.

Be very sure what to sacrifice code efficiency, maintainability, and understandability for. You already, absolutely know why performance is important, yet you also know what else is vital.

Read More

Enjoy the most popular posts, probably including:

Comments

  1. On March 13, 2009, 16:05 CET, Vladimir Carrer said:

    I think that CSS Micro optimization is very interesting subject. Yes probably “performance gains from optimizing CSS selectors will be small, and are not worth the costs”, but if we know what is better and faster in the first place, we should be able to write better(faster) CSS code. Little more research on this subject won’t heart.

  2. On March 15, 2009, 16:30 CET, Jens Meiert said:

    Vladimir, right, more research wouldn’t hurt, never hurts. However just stay alert when optimizing – what are the odds, what’s the price?

  3. On March 21, 2009, 16:24 CET, Carsten Senger said:

    Writing code with this kind of optimization in the first place is call “premature optimization” by software developers. Write code that is easy to read and does what it should with as few bugs as possible. If it has performance problems, search for the hot spots. Doing optimizations beforehand will make your code less maintainable.

    Of cause nobody tries to write bad code. But after reading Steve Souders’ post it seems that the performance of css selectors is totally irrelevant in real life.

Leave a Comment

Leave a Comment

Respect the comment guidelines. HTML allowed: <a href=""> <abbr title=""> <blockquote> <code> <em> <strong>

Found a mistake? Reward! Email me, jens@meiert.com.

You are here: meiert.com – Archive for 2009 – Performance of CSS Selectors is Irrelevant

Last update: March 12, 2009. Copyright 2000-2012 Jens O. Meiert.