Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2371595.2 Ops/sec
getElementsByClassName() 1530127.9 Ops/sec
getElementsByTagName() 1731594.2 Ops/sec
querySelector(#id) 1530182.1 Ops/sec
querySelector(.id) 1982867.2 Ops/sec
querySelectorAll(#id) 633549.7 Ops/sec
querySelectorAll(.id) 703865.6 Ops/sec
jQuery(#id) 841324.1 Ops/sec
jQuery(.id) 392268.9 Ops/sec
jQuery(tag#id) 221422.7 Ops/sec
jQuery(tag.id) 235320.5 Ops/sec
jQuery + getElementById 862292.4 Ops/sec
jQuery + getElementsByClassName 308051.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