Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Chrome 76
Mac OS X 10.13.4
Desktop
5 years ago
Test name Executions per second
getElementById() 2600365.0 Ops/sec
getElementsByClassName() 1661833.4 Ops/sec
getElementsByTagName() 1959427.6 Ops/sec
querySelector(#id) 1313888.8 Ops/sec
querySelector(.id) 1808833.8 Ops/sec
querySelectorAll(#id) 524671.6 Ops/sec
querySelectorAll(.id) 766044.3 Ops/sec
jQuery(#id) 559159.4 Ops/sec
jQuery(.id) 243950.8 Ops/sec
jQuery(tag#id) 147865.5 Ops/sec
jQuery(tag.id) 150382.2 Ops/sec
jQuery + getElementById 899117.8 Ops/sec
jQuery + getElementsByClassName 246134.0 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