Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Chrome 79
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 2867919.5 Ops/sec
getElementsByClassName() 1592385.6 Ops/sec
getElementsByTagName() 2059346.8 Ops/sec
querySelector(#id) 1573671.8 Ops/sec
querySelector(.id) 1740969.4 Ops/sec
querySelectorAll(#id) 806009.5 Ops/sec
querySelectorAll(.id) 954162.7 Ops/sec
jQuery(#id) 865199.9 Ops/sec
jQuery(.id) 424143.7 Ops/sec
jQuery(tag#id) 287124.9 Ops/sec
jQuery(tag.id) 277945.4 Ops/sec
jQuery + getElementById 1011524.4 Ops/sec
jQuery + getElementsByClassName 390355.3 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