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() 2531306.0 Ops/sec
getElementsByClassName() 2376577.5 Ops/sec
getElementsByTagName() 2755742.8 Ops/sec
querySelector(#id) 2638188.8 Ops/sec
querySelector(.id) 2661298.0 Ops/sec
querySelectorAll(#id) 877324.6 Ops/sec
querySelectorAll(.id) 1257360.6 Ops/sec
jQuery(#id) 2321249.5 Ops/sec
jQuery(.id) 829392.6 Ops/sec
jQuery(tag#id) 428149.4 Ops/sec
jQuery(tag.id) 489343.9 Ops/sec
jQuery + getElementById 1896673.6 Ops/sec
jQuery + getElementsByClassName 852069.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