Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Chrome 79
Windows 8.1
Desktop
4 years ago
Test name Executions per second
getElementById() 2614248.8 Ops/sec
getElementsByClassName() 1476051.8 Ops/sec
getElementsByTagName() 1938536.8 Ops/sec
querySelector(#id) 1449688.5 Ops/sec
querySelector(.id) 1980366.4 Ops/sec
querySelectorAll(#id) 715035.4 Ops/sec
querySelectorAll(.id) 914803.5 Ops/sec
jQuery(#id) 801877.9 Ops/sec
jQuery(.id) 387893.4 Ops/sec
jQuery(tag#id) 250744.4 Ops/sec
jQuery(tag.id) 257677.9 Ops/sec
jQuery + getElementById 952934.1 Ops/sec
jQuery + getElementsByClassName 351983.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