Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2158335.0 Ops/sec
getElementsByClassName() 1403049.6 Ops/sec
getElementsByTagName() 1758855.1 Ops/sec
querySelector(#id) 1357058.5 Ops/sec
querySelector(.id) 1824703.6 Ops/sec
querySelectorAll(#id) 635141.0 Ops/sec
querySelectorAll(.id) 734489.6 Ops/sec
jQuery(#id) 562095.8 Ops/sec
jQuery(.id) 195809.4 Ops/sec
jQuery(tag#id) 125573.5 Ops/sec
jQuery(tag.id) 120743.5 Ops/sec
jQuery + getElementById 720255.4 Ops/sec
jQuery + getElementsByClassName 179087.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


;