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

Revision 26 of this benchmark created on


Preparation HTML

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

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

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector Class
document.querySelector("#foo .bar span");
ready
querySelectorAll Class
document.querySelectorAll("#foo .bar span");
ready
querySelector Id
document.querySelector("#foo");
ready
querySelectorAll Id
document.querySelectorAll("#foo");
ready
getelementid
document.getElementById("foo");
ready

Revisions

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