Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Mac OS X 10.13
Desktop
6 years ago
Test name Executions per second
getElementById() 2597320.5 Ops/sec
getElementsByClassName() 2401674.8 Ops/sec
getElementsByTagName() 2879252.8 Ops/sec
querySelector(#id) 2759732.0 Ops/sec
querySelector(.id) 2739028.5 Ops/sec
querySelectorAll(#id) 729845.5 Ops/sec
querySelectorAll(.id) 1166809.8 Ops/sec
jQuery(#id) 2675495.2 Ops/sec
jQuery(.id) 831456.0 Ops/sec
jQuery(tag#id) 422714.2 Ops/sec
jQuery(tag.id) 439171.7 Ops/sec
jQuery + getElementById 2168157.8 Ops/sec
jQuery + getElementsByClassName 630398.9 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