jquery/standards — Issue #4: querySelectorAll is Often Surprisingly Slow
Author: paulirish
Created: 2011-10-20 18:59:58+00:00
State: open

In many cases, querySelectorAll is slower than the counterpart DOM method for simple selectors. For instance, querySelectorAll(‘tagName’) is slower than getElementsByTagName(‘tagName’).

## Specific Issues

* querySelectorAll is slower than the lower-level DOM methods
* querySelectorAll(tag) is slower than getElementsByTagName
* querySelectorAll(class) is slower than getElementsByClassName
* querySelectorAll(id) is slower than getElementById
* Action Items:
* Do benchmarking on all browsers
* File individual tickets with browser vendors for each instance in which querySelectorAll is slower than the lower-level DOM method
* Make sure that the same mistake is not repeated with queryScopedSelector
* Note: Why can we not just fix querySelectorAll? Are there cases where web authors are relying on the non-scoped behavior?
* External Contact: Browser vendors

## References

http://www.w3.org/TR/selectors-api/
http://www.w3.org/TR/selectors-api2/

## Conversation

http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/0277.html