On 7/24/13 5:39 PM, Ryosuke Niwa wrote:
Indeed. Note that querySelector implementations in WebKit and Blink optimize #foo, .foo, etc... so that they're equally if not faster than getElementsById, getElementsByClassName, etc...
I have a hard time reconciling that claim with either code-inspection of WebKit code, general considerations of what it takes to implement these methods, or the numbers I see in Chrome on http://jsperf.com/queryselector-vs-dom
Now I realize that for querySelectorAll vs getElementsByClassName that microbenchmark largely shows the "reuse same list vs have to create a new list" difference, but real-life code would show such a difference too, in many cases.
-Boris
