Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Firefox 70
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1822557.2 Ops/sec
getElementsByClassName() 1107742.2 Ops/sec
getElementsByTagName() 1616914.5 Ops/sec
querySelector(#id) 1611647.4 Ops/sec
querySelector(.id) 1612852.4 Ops/sec
querySelectorAll(#id) 583073.8 Ops/sec
querySelectorAll(.id) 656516.1 Ops/sec
jQuery(#id) 2087955.0 Ops/sec
jQuery(.id) 455947.2 Ops/sec
jQuery(tag#id) 269578.1 Ops/sec
jQuery(tag.id) 295644.2 Ops/sec
jQuery + getElementById 1270506.2 Ops/sec
jQuery + getElementsByClassName 358802.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