Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Firefox 58
Windows 7
Other
2025 years ago
Test name Executions per second
getElementById() 2765925.5 Ops/sec
getElementsByClassName() 2161435.2 Ops/sec
getElementsByTagName() 2833045.5 Ops/sec
querySelector(#id) 2077735.1 Ops/sec
querySelector(.id) 339443.1 Ops/sec
querySelectorAll(#id) 958980.4 Ops/sec
querySelectorAll(.id) 38531.0 Ops/sec
jQuery(#id) 2252931.5 Ops/sec
jQuery(.id) 686873.7 Ops/sec
jQuery(tag#id) 412124.0 Ops/sec
jQuery(tag.id) 39660.6 Ops/sec
jQuery + getElementById 2055678.5 Ops/sec
jQuery + getElementsByClassName 540861.9 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


;