Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
Firefox 67
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2172785.5 Ops/sec
getElementsByClassName() 1766031.6 Ops/sec
getElementsByTagName() 2369319.5 Ops/sec
querySelector(#id) 2356470.8 Ops/sec
querySelector(.id) 2087422.0 Ops/sec
querySelectorAll(#id) 744453.0 Ops/sec
querySelectorAll(.id) 821584.1 Ops/sec
jQuery(#id) 2411655.0 Ops/sec
jQuery(.id) 437184.9 Ops/sec
jQuery(tag#id) 239497.8 Ops/sec
jQuery(tag.id) 252053.4 Ops/sec
jQuery + getElementById 1603588.5 Ops/sec
jQuery + getElementsByClassName 508609.3 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