Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Mac OS X 10.14.1
Desktop
5 years ago
Test name Executions per second
getElementById() 4513589.5 Ops/sec
getElementsByClassName() 2854371.5 Ops/sec
getElementsByTagName() 3537532.8 Ops/sec
querySelector(#id) 2453997.8 Ops/sec
querySelector(.id) 3464263.8 Ops/sec
querySelectorAll(#id) 887870.0 Ops/sec
querySelectorAll(.id) 1216251.6 Ops/sec
jQuery(#id) 1568373.2 Ops/sec
jQuery(.id) 762818.1 Ops/sec
jQuery(tag#id) 416473.6 Ops/sec
jQuery(tag.id) 425860.1 Ops/sec
jQuery + getElementById 1688572.8 Ops/sec
jQuery + getElementsByClassName 675276.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


;