Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Firefox 52
Windows
Other
7 years ago
Test name Executions per second
getElementById() 10426577.0 Ops/sec
getElementsByClassName() 3707178.5 Ops/sec
getElementsByTagName() 4966152.0 Ops/sec
querySelector(#id) 5753616.5 Ops/sec
querySelector(.id) 399416.1 Ops/sec
querySelectorAll(#id) 1451566.4 Ops/sec
querySelectorAll(.id) 41502.8 Ops/sec
jQuery(#id) 2076718.8 Ops/sec
jQuery(.id) 410802.8 Ops/sec
jQuery(tag#id) 248140.0 Ops/sec
jQuery(tag.id) 36444.9 Ops/sec
jQuery + getElementById 2436280.2 Ops/sec
jQuery + getElementsByClassName 483516.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