Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2458287.5 Ops/sec
getElementsByClassName() 1518294.2 Ops/sec
getElementsByTagName() 1916883.6 Ops/sec
querySelector(#id) 1431886.0 Ops/sec
querySelector(.id) 1930463.0 Ops/sec
querySelectorAll(#id) 592472.7 Ops/sec
querySelectorAll(.id) 669444.1 Ops/sec
jQuery(#id) 626969.6 Ops/sec
jQuery(.id) 265129.8 Ops/sec
jQuery(tag#id) 156273.9 Ops/sec
jQuery(tag.id) 154062.2 Ops/sec
jQuery + getElementById 799412.7 Ops/sec
jQuery + getElementsByClassName 255086.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