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

Revision 5 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")[0];
ready
getElementsByTagName
const element = document.getElementsByTagName("p")[0];
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.