Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Mac OS X 10.11
Desktop
4 years ago
Test name Executions per second
getElementById() 1923139.0 Ops/sec
getElementsByClassName() 1094864.2 Ops/sec
getElementsByTagName() 1527761.8 Ops/sec
querySelector(#id) 1548540.9 Ops/sec
querySelector(.id) 1593426.4 Ops/sec
querySelectorAll(#id) 423132.5 Ops/sec
querySelectorAll(.id) 454665.0 Ops/sec
jQuery(#id) 2208857.0 Ops/sec
jQuery(.id) 234037.4 Ops/sec
jQuery(tag#id) 108555.9 Ops/sec
jQuery(tag.id) 131246.4 Ops/sec
jQuery + getElementById 1301774.2 Ops/sec
jQuery + getElementsByClassName 191318.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