querySelectorAll vs getElementById vs getElementsByTagName (v6)

Revision 6 of this benchmark created by Kieran on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector
var result = document.querySelector('#foo');
ready
getElementById
var result = document.getElementById('#foo');
ready
querySelectorAll[0]
var result = document.querySelectorAll('#foo')[0];
ready
querySelectorAll(tag)[0]
var result = document.querySelectorAll('p#foo')[0];
ready
getElementsByTagName[0]
var result = document.getElementsByTagName('p')[0];
ready

Revisions

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