Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.35 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2820883.2 Ops/sec
getElementsByClassName() 1640005.1 Ops/sec
getElementsByTagName() 2059333.9 Ops/sec
querySelector(#id) 1327981.9 Ops/sec
querySelector(.id) 1985551.0 Ops/sec
querySelectorAll(#id) 516973.4 Ops/sec
querySelectorAll(.id) 637373.7 Ops/sec
jQuery(#id) 749102.1 Ops/sec
jQuery(.id) 376982.4 Ops/sec
jQuery(tag#id) 224943.4 Ops/sec
jQuery(tag.id) 246513.5 Ops/sec
jQuery + getElementById 927295.9 Ops/sec
jQuery + getElementsByClassName 307703.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


;