Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Mac OS X 10.13.4
Desktop
6 years ago
Test name Executions per second
getElementById() 3911964.0 Ops/sec
getElementsByClassName() 2602260.8 Ops/sec
getElementsByTagName() 3326893.5 Ops/sec
querySelector(#id) 2452442.8 Ops/sec
querySelector(.id) 3182694.0 Ops/sec
querySelectorAll(#id) 957021.9 Ops/sec
querySelectorAll(.id) 1188087.9 Ops/sec
jQuery(#id) 1370658.6 Ops/sec
jQuery(.id) 648017.9 Ops/sec
jQuery(tag#id) 376155.7 Ops/sec
jQuery(tag.id) 363462.2 Ops/sec
jQuery + getElementById 1425264.2 Ops/sec
jQuery + getElementsByClassName 567210.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


;