getElementById vs. querySelector (v248)

Revision 248 of this benchmark created on


Preparation HTML

<p id="pp-0">Foo</p>
<p id="pp-1">Bar</p>
<p id="pp-2">Baz</p>
<p class="component-pp-0">Foo</p>
<p class="component-pp-1">Bar</p>
<p class="component-pp-2">Baz</p>

Setup

var id = "pp-1";

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var bar = document.getElementById(id);
ready
querySelector
var bar = document.querySelector(".component-" + id);
ready

Revisions

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