Ok, querySelectorAll was built to run once and work, without regard to the fact that it might run thousands of times over. Imagine a routine querySelectorAll_prep that traverses the document tree and does things like hashnodes[e.nodeName].push(e); So all the div nodes are in the array hashnodes["div"}. If you have a div selector then just run down this array. But more common is nodetype with class. hashnodes[e.nodeName + "||" + e.className].push(e); If the selector is div.class then you just scoot down a very short array. Beyond this, there are no checks needed for an unadorned div.class, just apply the attributes. Even if there are other checks, like div.class and foo=bar, at least you have a short array to check. You might also set hashnodes["||" + e.className].push(e); That lets you look for .xyz i.e. any element of class xyz. And you need to put every element in hashnodes["*"] because some selectors are just exotic and not tied to a particular node type or class. But it's a little more complicated. A selector could be p.dog,div.cat That's two selectors in one. We would have to separate them, split(","); and iterate over the two selectors, as though they had been separate from the get-go. Not hard, just another wrinkle. As I do today, getComputedStyle needs to run querySelectorAll on one particular node, not needing any of the above machinery. That is the second argument to querySelectorAll as it stands today, a particular node to start at, but it tries to do the subtree, so I remove the children first, then run querySelectorAll(selectors, e), then put the children back. It's gross. See third.js line 3947. Before you or I or anyone takes a whack at this, I'm going to list out all the selectors from stackoverflow, to get an idea of what is there, and what kind of savings we might realize from the aforementioned node hashing. Glad to see you back on the list, we miss your talent and your insights. Maybe you could tackle one of these projects, if you have time, gopher or querySelectorAll optimization or infinite loop debugging, whichever one tickles your fancy. Or anyone else who wants to step up. I'll keep doing some light research. Karl Dahlke