Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1553498.0 Ops/sec
getElementsByClassName() 1531880.4 Ops/sec
getElementsByTagName() 1809213.2 Ops/sec
querySelector(#id) 1891645.9 Ops/sec
querySelector(.id) 1701211.2 Ops/sec
querySelectorAll(#id) 733555.6 Ops/sec
querySelectorAll(.id) 833124.0 Ops/sec
jQuery(#id) 1951075.1 Ops/sec
jQuery(.id) 503972.3 Ops/sec
jQuery(tag#id) 302763.9 Ops/sec
jQuery(tag.id) 315887.4 Ops/sec
jQuery + getElementById 1283979.2 Ops/sec
jQuery + getElementsByClassName 539358.2 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