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
5 years ago
Test name Executions per second
getElementById() 1459338.0 Ops/sec
getElementsByClassName() 1001316.5 Ops/sec
getElementsByTagName() 1165467.9 Ops/sec
querySelector(#id) 824451.8 Ops/sec
querySelector(.id) 1179338.9 Ops/sec
querySelectorAll(#id) 304577.0 Ops/sec
querySelectorAll(.id) 391247.1 Ops/sec
jQuery(#id) 378260.8 Ops/sec
jQuery(.id) 159651.8 Ops/sec
jQuery(tag#id) 94245.4 Ops/sec
jQuery(tag.id) 99750.2 Ops/sec
jQuery + getElementById 555737.6 Ops/sec
jQuery + getElementsByClassName 170737.7 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


;