Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Windows 7
Desktop
4 years ago
Test name Executions per second
getElementById() 3191841.2 Ops/sec
getElementsByClassName() 1669816.4 Ops/sec
getElementsByTagName() 2590529.5 Ops/sec
querySelector(#id) 2592844.8 Ops/sec
querySelector(.id) 2633757.0 Ops/sec
querySelectorAll(#id) 924538.9 Ops/sec
querySelectorAll(.id) 1034438.6 Ops/sec
jQuery(#id) 3442298.0 Ops/sec
jQuery(.id) 531354.7 Ops/sec
jQuery(tag#id) 278564.5 Ops/sec
jQuery(tag.id) 291812.2 Ops/sec
jQuery + getElementById 2194538.2 Ops/sec
jQuery + getElementsByClassName 467614.1 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