getElementById vs. querySelector (v10)

Revision 10 of this benchmark created on


Description

Compare the speed of getElementById to querySelector

Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var bar = document.getElementById("bar");
ready
querySelector
var bar = document.querySelector("#bar");
ready
XPath
var bar = document.evaluate("//*[@id='bar']", document, null, 9, null).singleNodeValue;
ready

Revisions

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