Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Mac OS X 10.14.0
Desktop
5 years ago
Test name Executions per second
getElementById() 2925385.8 Ops/sec
getElementsByClassName() 1918716.9 Ops/sec
getElementsByTagName() 2331298.8 Ops/sec
querySelector(#id) 1692290.1 Ops/sec
querySelector(.id) 2450011.2 Ops/sec
querySelectorAll(#id) 694040.2 Ops/sec
querySelectorAll(.id) 860951.2 Ops/sec
jQuery(#id) 1041487.6 Ops/sec
jQuery(.id) 515240.8 Ops/sec
jQuery(tag#id) 271605.6 Ops/sec
jQuery(tag.id) 288863.2 Ops/sec
jQuery + getElementById 1105123.1 Ops/sec
jQuery + getElementsByClassName 411503.5 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