Test name | Executions per second |
---|---|
getElementsByClassName | 224153.1 Ops/sec |
querySelectorAll | 8944.1 Ops/sec |
<style>.searchMe {border: 1px sold red;}</style>
<table id="tableTest"></table>
for(var i=0; i<10000; ++i)
{
var cell = tableTest.insertRow(-1).insertCell(-1);
if(i%2==0)
cell.classList.add('searchMe');
}
var found = tableTest.getElementsByClassName('searchMe');
tableTest.rows[0].cells[0].textContent = found.length;
var found = tableTest.querySelectorAll('.searchMe');
tableTest.rows[0].cells[0].textContent = found.length;