Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Chrome 79
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 3394937.0 Ops/sec
getElementsByClassName() 2116223.8 Ops/sec
getElementsByTagName() 2594951.8 Ops/sec
querySelector(#id) 2128968.5 Ops/sec
querySelector(.id) 2759813.2 Ops/sec
querySelectorAll(#id) 1205894.6 Ops/sec
querySelectorAll(.id) 1518657.5 Ops/sec
jQuery(#id) 1083573.6 Ops/sec
jQuery(.id) 514626.2 Ops/sec
jQuery(tag#id) 386582.7 Ops/sec
jQuery(tag.id) 402425.8 Ops/sec
jQuery + getElementById 1341577.9 Ops/sec
jQuery + getElementsByClassName 487000.2 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