Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
Firefox 62
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2330418.8 Ops/sec
getElementsByClassName() 2147247.5 Ops/sec
getElementsByTagName() 2360365.2 Ops/sec
querySelector(#id) 2452867.2 Ops/sec
querySelector(.id) 2398785.0 Ops/sec
querySelectorAll(#id) 636767.8 Ops/sec
querySelectorAll(.id) 979565.6 Ops/sec
jQuery(#id) 2382380.2 Ops/sec
jQuery(.id) 514811.9 Ops/sec
jQuery(tag#id) 245646.8 Ops/sec
jQuery(tag.id) 328128.5 Ops/sec
jQuery + getElementById 2070920.9 Ops/sec
jQuery + getElementsByClassName 532792.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