querySelector vs querySelectorAll vs getElementById vs getElementsByClassName vs getElementsByTagName (v17)

Revision 17 of this benchmark created on


Preparation HTML

<p id="foo" class="foo">
  <span class="bar"><span>,,,</span></span>
</p>

Test runner

Ready to run.

Testing in
TestOps/sec
queryselector
document.querySelector("p .bar");
ready
elementselector
var test = document.getElementsByTagName('p');

test.getElementsByClassName('bar');
ready
querySelector Id
 
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.