Jens Oliver Meiert

Performance of CSS Selectors Is Irrelevant

Post from March 12, 2009 (↻ June 10, 2021), filed under .

This and many other posts are also available as a pretty, well-behaved ebook: On Web Development.

…if you like to have a strict read of Steve Souders’ recent research. We’ve still got few but now a few more numbers backing up what we always suspected, that merely optimizing selectors is micro-optimization, micro-optimization that may shave off mere microseconds 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 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 follows after:

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

Figure: Page render time and number of CSS rules. (Copyright 2009 Steve Souders.)

Be sure what to sacrifice code efficiency, maintainability, and understandability for. We know why performance is important, we know what else matters. Focusing on selectors means saving at the wrong end.

Tweet this? (If it changed your life, you delight me with a coffee.)

About Me

Jens Oliver Meiert, on April 29, 2020.

I’m Jens Oliver Meiert, and I’m an engineering manager and author. I’ve worked as a technical lead for Google, I’m close to the W3C and the WHATWG, and I write and review books for O’Reilly. Other than that, I love trying things, sometimes including philosophy, art, and adventure. Here on I share some of my views and experiences.

If you have questions or suggestions about what I write, please leave a comment (if available) or a message.

Comments (Closed)

  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 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.

Read More

Have a look at the most popular posts, possibly including:

Looking for a way to comment? Comments have been disabled, unfortunately.

Cover: The Web Development Glossary.

Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.

Stay up-to-date? Follow me by feed or on Twitter.

Found a mistake? Email me,

You are here: Home → Archive → 2009 → Performance of CSS Selectors Is Irrelevant

Last update: June 10, 2021

Professional frontend developers produce valid HTML and CSS.