Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Mac OS X 10.14
Desktop
5 years ago
Test name Executions per second
getElementById() 2599367.2 Ops/sec
getElementsByClassName() 2308965.5 Ops/sec
getElementsByTagName() 2386913.0 Ops/sec
querySelector(#id) 2629890.0 Ops/sec
querySelector(.id) 2729382.2 Ops/sec
querySelectorAll(#id) 973454.6 Ops/sec
querySelectorAll(.id) 1151035.6 Ops/sec
jQuery(#id) 3021137.2 Ops/sec
jQuery(.id) 884707.1 Ops/sec
jQuery(tag#id) 499108.2 Ops/sec
jQuery(tag.id) 532982.9 Ops/sec
jQuery + getElementById 2196044.5 Ops/sec
jQuery + getElementsByClassName 812363.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