Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Chrome 85
Windows
Desktop
3 years ago
Test name Executions per second
getElementById 1480017.0 Ops/sec
jQuery (tag.id) 106335.8 Ops/sec
jQuery (tag#id) 105525.5 Ops/sec
jQuery (.id) 147349.6 Ops/sec
jQuery (#id) 636182.2 Ops/sec
Cash + getElementsByClassName 321682.4 Ops/sec
Cash + getElementById 517994.9 Ops/sec
Cash (tag.id) 165558.3 Ops/sec
jQuery + getElementById 527441.1 Ops/sec
Cash (tag#id) 153977.8 Ops/sec
Cash (#id) 788681.3 Ops/sec
querySelectorAll (.id) 585554.1 Ops/sec
querySelectorAll (#id) 387985.9 Ops/sec
querySelector (.id) 1553249.0 Ops/sec
querySelector (#id) 754353.6 Ops/sec
getElementsByTagName 980386.0 Ops/sec
getElementsByClassName 889238.9 Ops/sec
Cash (.id) 204040.2 Ops/sec
jQuery + getElementsByClassName 172150.6 Ops/sec
HTML Preparation code:
Tests:
  • getElementById

  • getElementsByClassName

  • getElementsByTagName

  • querySelector (#id)

  • querySelector (.id)

  • querySelectorAll (#id)

  • querySelectorAll (.id)

  • Cash (#id)

  • Cash (.id)

  • Cash (tag#id)

  • Cash (tag.id)

  • Cash + getElementById

  • Cash + getElementsByClassName

  • jQuery (#id)

  • jQuery (.id)

  • jQuery (tag#id)

  • jQuery (tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName