Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows
Other
7 years ago
Test name Executions per second
getElementById() 1479426.9 Ops/sec
getElementsByClassName() 1168979.1 Ops/sec
getElementsByTagName() 1159843.1 Ops/sec
querySelector(#id) 953780.9 Ops/sec
querySelector(.id) 144740.6 Ops/sec
querySelectorAll(#id) 37636.5 Ops/sec
querySelectorAll(.id) 31565.2 Ops/sec
jQuery(#id) 978476.4 Ops/sec
jQuery(.id) 432286.4 Ops/sec
jQuery(tag#id) 33176.7 Ops/sec
jQuery(tag.id) 30143.4 Ops/sec
jQuery + getElementById 1061103.2 Ops/sec
jQuery + getElementsByClassName 248953.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