getElementById vs. querySelector (v99)

Revision 99 of this benchmark created on


Description

Compare the speed of document.getElementById to element.querySelector

Preparation HTML

<p id="foo">
    <p id="bar">Bar</p>
</p>

Setup

var foo = document.getElementById("foo");

Test runner

Ready to run.

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

Revisions

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