Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 4525814.0 Ops/sec
getElementsByClassName() 2944239.5 Ops/sec
getElementsByTagName() 3639985.8 Ops/sec
querySelector(#id) 2599597.8 Ops/sec
querySelector(.id) 3650346.5 Ops/sec
querySelectorAll(#id) 945962.7 Ops/sec
querySelectorAll(.id) 1238470.6 Ops/sec
jQuery(#id) 1492943.0 Ops/sec
jQuery(.id) 815187.9 Ops/sec
jQuery(tag#id) 406891.1 Ops/sec
jQuery(tag.id) 436169.3 Ops/sec
jQuery + getElementById 1732291.9 Ops/sec
jQuery + getElementsByClassName 539149.9 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