Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0
Firefox 73
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 3941835.2 Ops/sec
getElementsByClassName() 2406494.5 Ops/sec
getElementsByTagName() 3042597.0 Ops/sec
querySelector(#id) 3095320.8 Ops/sec
querySelector(.id) 3217403.5 Ops/sec
querySelectorAll(#id) 1086249.2 Ops/sec
querySelectorAll(.id) 1283376.4 Ops/sec
jQuery(#id) 4309199.5 Ops/sec
jQuery(.id) 1023436.9 Ops/sec
jQuery(tag#id) 518964.2 Ops/sec
jQuery(tag.id) 565635.8 Ops/sec
jQuery + getElementById 2489102.8 Ops/sec
jQuery + getElementsByClassName 804110.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