Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0
Firefox 51
Windows
Other
7 years ago
Test name Executions per second
getElementById() 11524929.0 Ops/sec
getElementsByClassName() 3898306.8 Ops/sec
getElementsByTagName() 5164641.5 Ops/sec
querySelector(#id) 5969228.5 Ops/sec
querySelector(.id) 487401.5 Ops/sec
querySelectorAll(#id) 1402318.4 Ops/sec
querySelectorAll(.id) 61134.0 Ops/sec
jQuery(#id) 2072231.9 Ops/sec
jQuery(.id) 434259.4 Ops/sec
jQuery(tag#id) 295787.0 Ops/sec
jQuery(tag.id) 49674.0 Ops/sec
jQuery + getElementById 2362214.8 Ops/sec
jQuery + getElementsByClassName 521291.1 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