Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.13.6
Desktop
5 years ago
Test name Executions per second
getElementById() 2101538.0 Ops/sec
getElementsByClassName() 1141648.0 Ops/sec
getElementsByTagName() 1385534.9 Ops/sec
querySelector(#id) 1050554.4 Ops/sec
querySelector(.id) 1338923.1 Ops/sec
querySelectorAll(#id) 397250.4 Ops/sec
querySelectorAll(.id) 462797.1 Ops/sec
jQuery(#id) 423675.7 Ops/sec
jQuery(.id) 134065.8 Ops/sec
jQuery(tag#id) 46349.6 Ops/sec
jQuery(tag.id) 45096.6 Ops/sec
jQuery + getElementById 584431.6 Ops/sec
jQuery + getElementsByClassName 167426.7 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