Testing multiple IDs selection (v2)

Revision 2 of this benchmark created on


Setup

for (i = 0; i < 1000; i++) {
  let textNode, spanElement;
  textNode = document.createTextNode(i + " ");
  spanElement = document.createElement("span");
  spanElement.id = "foo";
  spanElement.classList.add("bar")
  spanElement.appendChild(textNode);
  document.body.appendChild(spanElement);
}

Test runner

Ready to run.

Testing in
TestOps/sec
QuerySelectorAll + attribute selector on id
document.querySelectorAll("[id=foo");
ready
QuerySelectorAll + class selector
document.querySelectorAll(".bar");
ready
getElementsByClassName + class selector
document.getElementsByClassName("bar")
ready
QuerySelectorAll + attribute selector on class
document.querySelectorAll("[class=bar]");
ready

Revisions

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