Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 2988002.0 Ops/sec
getElementsByClassName() 1833028.6 Ops/sec
getElementsByTagName() 2265177.0 Ops/sec
querySelector(#id) 1667070.1 Ops/sec
querySelector(.id) 2433686.8 Ops/sec
querySelectorAll(#id) 724252.9 Ops/sec
querySelectorAll(.id) 887903.5 Ops/sec
jQuery(#id) 1025535.9 Ops/sec
jQuery(.id) 497867.0 Ops/sec
jQuery(tag#id) 278545.3 Ops/sec
jQuery(tag.id) 302132.6 Ops/sec
jQuery + getElementById 1140636.6 Ops/sec
jQuery + getElementsByClassName 396194.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


;