Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Firefox 60
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2073165.5 Ops/sec
getElementsByClassName() 1955958.1 Ops/sec
getElementsByTagName() 2163316.5 Ops/sec
querySelector(#id) 2211168.5 Ops/sec
querySelector(.id) 2213146.5 Ops/sec
querySelectorAll(#id) 652551.5 Ops/sec
querySelectorAll(.id) 947244.8 Ops/sec
jQuery(#id) 2218158.2 Ops/sec
jQuery(.id) 603428.6 Ops/sec
jQuery(tag#id) 322430.5 Ops/sec
jQuery(tag.id) 361015.3 Ops/sec
jQuery + getElementById 1838027.0 Ops/sec
jQuery + getElementsByClassName 506209.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