Selectors ClassVsData && DocumentVsElement (v2)

Revision 2 of this benchmark created on


Preparation HTML

<div id="div1"></div>
<div id="div2">
<div id="innerdiv" class="divclass" data-dataselector></div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
classElemSelector
outernode = document.getElementById('div1').nextSibling;
node = outernode.querySelector('.divclass');
ready
classDocSelector
//node = document.getElementById('div1');
node = document.querySelector('.divclass');
ready
dataElemSelector
outernode = document.getElementById('div1').nextSibling;
node = outernode.querySelector('[data-dataselector]');
ready
dataDocSelector
//node = document.getElementById('div1');
node = document.querySelector('[data-dataselector]');
ready

Revisions

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