Javascript selector vs id/class/all (v2)

Revision 2 of this benchmark created by William Manco on


Preparation HTML

<div id="myid"></div>
<div class="myclass"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
Selector ID
document.getElementById('myid');
ready
Selector Class
document.getElementsByClassName('myclass');
ready
Selector All -> ID
document.querySelectorAll('#myid');
ready
Selector All -> Class
document.querySelectorAll('.myid');
ready

Revisions

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

  • Revision 1: published by William Manco on
  • Revision 2: published by William Manco on