Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36
Chrome 75
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 2419166.8 Ops/sec
getElementsByClassName() 1261576.2 Ops/sec
getElementsByTagName() 1448231.9 Ops/sec
querySelector(#id) 1050700.0 Ops/sec
querySelector(.id) 1379060.9 Ops/sec
querySelectorAll(#id) 463234.3 Ops/sec
querySelectorAll(.id) 560155.0 Ops/sec
jQuery(#id) 661653.9 Ops/sec
jQuery(.id) 292840.3 Ops/sec
jQuery(tag#id) 188427.8 Ops/sec
jQuery(tag.id) 197920.6 Ops/sec
jQuery + getElementById 858211.1 Ops/sec
jQuery + getElementsByClassName 289421.8 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