Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0
Firefox 74
Linux
Desktop
5 years ago
Test name Executions per second
querySelectorAll 185020.0 Ops/sec
getElementsByClassName 977338.7 Ops/sec
HTML Preparation code:
AخA
 
1
<div class="test"></div>
Tests:
  • querySelectorAll

     
    document.querySelectorAll(".test").forEach(x=>x.style.color='red')
  • getElementsByClassName

     
    Array.from(document.getElementsByClassName(".test")).forEach(x=>x.style.color='red')