Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Chrome 62
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3204471.2 Ops/sec
getElementsByClassName() 2250989.5 Ops/sec
getElementsByTagName() 2618590.2 Ops/sec
querySelector(#id) 2919829.5 Ops/sec
querySelector(.id) 706873.9 Ops/sec
querySelectorAll(#id) 1219522.0 Ops/sec
querySelectorAll(.id) 99780.0 Ops/sec
jQuery(#id) 1204293.6 Ops/sec
jQuery(.id) 657957.4 Ops/sec
jQuery(tag#id) 418285.7 Ops/sec
jQuery(tag.id) 78081.9 Ops/sec
jQuery + getElementById 1262398.0 Ops/sec
jQuery + getElementsByClassName 395507.5 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