Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 5071199.0 Ops/sec
getElementsByClassName() 3060397.2 Ops/sec
getElementsByTagName() 3858233.2 Ops/sec
querySelector(#id) 2744517.5 Ops/sec
querySelector(.id) 3934330.5 Ops/sec
querySelectorAll(#id) 1315036.6 Ops/sec
querySelectorAll(.id) 1701625.1 Ops/sec
jQuery(#id) 1566820.9 Ops/sec
jQuery(.id) 795381.6 Ops/sec
jQuery(tag#id) 492587.6 Ops/sec
jQuery(tag.id) 492606.4 Ops/sec
jQuery + getElementById 1938604.0 Ops/sec
jQuery + getElementsByClassName 733191.2 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