Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 3895963.5 Ops/sec
getElementsByClassName() 2349257.8 Ops/sec
getElementsByTagName() 3051445.5 Ops/sec
querySelector(#id) 2270423.0 Ops/sec
querySelector(.id) 3242285.2 Ops/sec
querySelectorAll(#id) 976861.2 Ops/sec
querySelectorAll(.id) 1132879.8 Ops/sec
jQuery(#id) 1372309.0 Ops/sec
jQuery(.id) 612984.8 Ops/sec
jQuery(tag#id) 320565.7 Ops/sec
jQuery(tag.id) 350027.2 Ops/sec
jQuery + getElementById 1465924.6 Ops/sec
jQuery + getElementsByClassName 613352.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