Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 4541978.5 Ops/sec
getElementsByClassName() 2857699.2 Ops/sec
getElementsByTagName() 3602302.8 Ops/sec
querySelector(#id) 2657521.0 Ops/sec
querySelector(.id) 3580390.5 Ops/sec
querySelectorAll(#id) 1208520.8 Ops/sec
querySelectorAll(.id) 1557357.1 Ops/sec
jQuery(#id) 1380693.2 Ops/sec
jQuery(.id) 697621.1 Ops/sec
jQuery(tag#id) 435776.4 Ops/sec
jQuery(tag.id) 468459.4 Ops/sec
jQuery + getElementById 1714640.8 Ops/sec
jQuery + getElementsByClassName 661642.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