Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
Firefox 68
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2982086.0 Ops/sec
getElementsByClassName() 2484187.0 Ops/sec
getElementsByTagName() 3161747.5 Ops/sec
querySelector(#id) 2924440.5 Ops/sec
querySelector(.id) 2624133.2 Ops/sec
querySelectorAll(#id) 1011932.1 Ops/sec
querySelectorAll(.id) 1060107.5 Ops/sec
jQuery(#id) 3381543.0 Ops/sec
jQuery(.id) 948534.6 Ops/sec
jQuery(tag#id) 537413.9 Ops/sec
jQuery(tag.id) 555748.4 Ops/sec
jQuery + getElementById 2288575.0 Ops/sec
jQuery + getElementsByClassName 840929.0 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