Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Chrome 61
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2311099.5 Ops/sec
getElementsByClassName() 1552902.8 Ops/sec
getElementsByTagName() 1954833.4 Ops/sec
querySelector(#id) 1861050.9 Ops/sec
querySelector(.id) 421995.9 Ops/sec
querySelectorAll(#id) 798021.4 Ops/sec
querySelectorAll(.id) 66983.6 Ops/sec
jQuery(#id) 902727.4 Ops/sec
jQuery(.id) 516143.5 Ops/sec
jQuery(tag#id) 301649.4 Ops/sec
jQuery(tag.id) 55708.8 Ops/sec
jQuery + getElementById 919324.9 Ops/sec
jQuery + getElementsByClassName 300934.6 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