QSA selector vs. regular JS selection (v3)

Revision 3 of this benchmark created by Jon-Carlos Rivera on


Preparation HTML

<div id="div">
  <a href="#" class="link">Link</a>
</div>
<div>
  <a href="#" class="link">Link</a>
</div>
<br />
<br />
<div id="TestResults">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
document.getElementById("div");
ready
qsa("#id")
document.querySelector("#div")
ready
getElementsByClassName
Array.prototype.slice.call(document.getElementsByClassName("link"));
ready
qsa(".className")
document.querySelectorAll(".link");
ready
getElementsByTagName
Array.prototype.slice.call(document.getElementsByTagName("div"));
ready
qsa("tagName")
document.querySelectorAll("div");
ready

Revisions

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

  • Revision 1: published on
  • Revision 3: published by Jon-Carlos Rivera on