querySelector vs getElement(s)ByWhatever vs .firstElementChild (v2)

Revision 2 of this benchmark created on


Preparation HTML

<p id="id" class="class">some text 0</p>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector
const element = document.querySelector(".class");
ready
getElementsByClassName
const element = document.getElementsByClassName("class");
ready
getElementsByTagName
const element = document.getElementsByTagName("p");
ready
getElementById
const element = document.getElementById("id");
ready
firstElementChild
const element = document.body.firstElementChild;
ready

Revisions

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