getElementById vs. querySelector vs. getElementByClassname (v213)

Revision 213 of this benchmark created on


Preparation HTML

<p id="foo" class="first">Foo</p>
<p id="bar" class="second other">Bar</p>
<p id="baz" class="third other">Baz</p>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var bar = document.getElementById("bar");
ready
querySelector
var bar = document.querySelector("#bar");
ready
getElementByClassName
var bar = document.getElementByClassName("first");
ready

Revisions

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