Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Ubuntu
Desktop
4 years ago
Test name Executions per second
getElementById() 2334306.5 Ops/sec
getElementsByClassName() 1360830.5 Ops/sec
getElementsByTagName() 1994814.5 Ops/sec
querySelector(#id) 1906334.2 Ops/sec
querySelector(.id) 1924886.6 Ops/sec
querySelectorAll(#id) 654776.6 Ops/sec
querySelectorAll(.id) 749789.9 Ops/sec
jQuery(#id) 2857473.0 Ops/sec
jQuery(.id) 537129.8 Ops/sec
jQuery(tag#id) 311631.4 Ops/sec
jQuery(tag.id) 336492.6 Ops/sec
jQuery + getElementById 1712952.4 Ops/sec
jQuery + getElementsByClassName 468474.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


;