Run details:
Mozilla/5.0 (Linux; Android 9; Nokia 2.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.143 Mobile Safari/537.36
Chrome Mobile 75
Android
Mobile
5 years ago
Test name Executions per second
querySelectorAll 50826.6 Ops/sec
getElementsByClassName 134730.9 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')