Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3709670.2 Ops/sec
getElementsByClassName() 2172497.0 Ops/sec
getElementsByTagName() 2601958.8 Ops/sec
querySelector(#id) 2148336.0 Ops/sec
querySelector(.id) 2877992.2 Ops/sec
querySelectorAll(#id) 732644.9 Ops/sec
querySelectorAll(.id) 1025329.8 Ops/sec
jQuery(#id) 1177612.6 Ops/sec
jQuery(.id) 585479.9 Ops/sec
jQuery(tag#id) 337692.4 Ops/sec
jQuery(tag.id) 369056.8 Ops/sec
jQuery + getElementById 1360682.8 Ops/sec
jQuery + getElementsByClassName 456474.5 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