Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Chrome 70
Mac OS X 10.12.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3695087.5 Ops/sec
getElementsByClassName() 2315197.5 Ops/sec
getElementsByTagName() 2962680.8 Ops/sec
querySelector(#id) 2112403.8 Ops/sec
querySelector(.id) 3025533.5 Ops/sec
querySelectorAll(#id) 759287.8 Ops/sec
querySelectorAll(.id) 982264.2 Ops/sec
jQuery(#id) 1305262.8 Ops/sec
jQuery(.id) 604532.7 Ops/sec
jQuery(tag#id) 312878.5 Ops/sec
jQuery(tag.id) 351125.0 Ops/sec
jQuery + getElementById 1450871.5 Ops/sec
jQuery + getElementsByClassName 459072.7 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