[whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments

Boris Zbarsky bzbarsky at MIT.EDU
Thu Jul 25 09:02:50 PDT 2013


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





More information about the whatwg mailing list