Test name | Executions per second |
---|---|
querySelectorAll | 380632.4 Ops/sec |
getElementsByClassName | 273318.1 Ops/sec |
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
const allTests = document.querySelectorAll('.test');
allTests.forEach(function (test) {});
const allTests = document.getElementsByClassName('test');
const arrayAllTests = Array.from(allTests);
arrayAllTests.forEach(function (test) {});