Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
Chrome 60
Windows
Other
7 years ago
Test name Executions per second
getElementById() 1247989.1 Ops/sec
getElementsByClassName() 858184.9 Ops/sec
getElementsByTagName() 1109816.1 Ops/sec
querySelector(#id) 989381.6 Ops/sec
querySelector(.id) 191716.4 Ops/sec
querySelectorAll(#id) 373977.8 Ops/sec
querySelectorAll(.id) 32003.7 Ops/sec
jQuery(#id) 297517.5 Ops/sec
jQuery(.id) 138875.9 Ops/sec
jQuery(tag#id) 79148.5 Ops/sec
jQuery(tag.id) 24702.3 Ops/sec
jQuery + getElementById 430358.2 Ops/sec
jQuery + getElementsByClassName 113579.8 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