Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows
Other
8 years ago
Test name Executions per second
getElementById() 1477386.5 Ops/sec
getElementsByClassName() 1100864.4 Ops/sec
getElementsByTagName() 1102600.4 Ops/sec
querySelector(#id) 922251.6 Ops/sec
querySelector(.id) 140130.1 Ops/sec
querySelectorAll(#id) 33240.7 Ops/sec
querySelectorAll(.id) 27750.3 Ops/sec
jQuery(#id) 982105.6 Ops/sec
jQuery(.id) 390267.9 Ops/sec
jQuery(tag#id) 28830.4 Ops/sec
jQuery(tag.id) 26528.9 Ops/sec
jQuery + getElementById 1048541.4 Ops/sec
jQuery + getElementsByClassName 239052.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