Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
Chrome 55
Mac OS X 10.10.5
Desktop
5 years ago
Test name Executions per second
querySelectorAll 226454.6 Ops/sec
getElementsByClassName 367830.5 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')