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() 3242975.0 Ops/sec
getElementsByClassName() 2085205.8 Ops/sec
getElementsByTagName() 2539621.0 Ops/sec
querySelector(#id) 1768560.0 Ops/sec
querySelector(.id) 2390695.0 Ops/sec
querySelectorAll(#id) 722577.6 Ops/sec
querySelectorAll(.id) 878100.3 Ops/sec
jQuery(#id) 1158138.9 Ops/sec
jQuery(.id) 586065.9 Ops/sec
jQuery(tag#id) 318311.6 Ops/sec
jQuery(tag.id) 333221.8 Ops/sec
jQuery + getElementById 1295066.4 Ops/sec
jQuery + getElementsByClassName 534165.6 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


;