Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2308318.0 Ops/sec
getElementsByClassName() 1562893.4 Ops/sec
getElementsByTagName() 1788822.5 Ops/sec
querySelector(#id) 1146157.9 Ops/sec
querySelector(.id) 2060195.4 Ops/sec
querySelectorAll(#id) 704132.7 Ops/sec
querySelectorAll(.id) 958876.4 Ops/sec
jQuery(#id) 809075.1 Ops/sec
jQuery(.id) 396871.7 Ops/sec
jQuery(tag#id) 186872.5 Ops/sec
jQuery(tag.id) 166429.9 Ops/sec
jQuery + getElementById 831982.9 Ops/sec
jQuery + getElementsByClassName 282538.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