Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
Chrome 75
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 4585409.0 Ops/sec
getElementsByClassName() 2984391.2 Ops/sec
getElementsByTagName() 3603243.8 Ops/sec
querySelector(#id) 2517479.8 Ops/sec
querySelector(.id) 3600280.5 Ops/sec
querySelectorAll(#id) 1177244.5 Ops/sec
querySelectorAll(.id) 1474712.8 Ops/sec
jQuery(#id) 1403820.0 Ops/sec
jQuery(.id) 529272.2 Ops/sec
jQuery(tag#id) 357518.8 Ops/sec
jQuery(tag.id) 368603.7 Ops/sec
jQuery + getElementById 1363439.9 Ops/sec
jQuery + getElementsByClassName 545932.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