Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0
Firefox 63
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1689674.9 Ops/sec
getElementsByClassName() 1694969.9 Ops/sec
getElementsByTagName() 1920866.8 Ops/sec
querySelector(#id) 1881976.2 Ops/sec
querySelector(.id) 1915845.4 Ops/sec
querySelectorAll(#id) 625301.6 Ops/sec
querySelectorAll(.id) 905149.4 Ops/sec
jQuery(#id) 1821363.8 Ops/sec
jQuery(.id) 595298.3 Ops/sec
jQuery(tag#id) 284726.6 Ops/sec
jQuery(tag.id) 322704.4 Ops/sec
jQuery + getElementById 1427226.0 Ops/sec
jQuery + getElementsByClassName 500072.7 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