Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
Chrome 84
Windows
Desktop
4 years ago
Test name Executions per second
getElementsById + getElementsByClassName 2971299.8 Ops/sec
querySelector + querySelector 1929810.5 Ops/sec
querySelector 2452812.5 Ops/sec
cache + getElementsByClassName 3284783.2 Ops/sec
cache + querySelector 2905447.8 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests:
  • getElementsById + getElementsByClassName

  • querySelector + querySelector

  • querySelector

  • cache + getElementsByClassName

  • cache + querySelector