Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Mac OS X 10.13.4
Desktop
6 years ago
Test name Executions per second
getElementById() 3527107.2 Ops/sec
getElementsByClassName() 2250819.5 Ops/sec
getElementsByTagName() 2775986.8 Ops/sec
querySelector(#id) 2010814.9 Ops/sec
querySelector(.id) 2839210.5 Ops/sec
querySelectorAll(#id) 663770.4 Ops/sec
querySelectorAll(.id) 865499.9 Ops/sec
jQuery(#id) 1301122.0 Ops/sec
jQuery(.id) 620015.2 Ops/sec
jQuery(tag#id) 327087.3 Ops/sec
jQuery(tag.id) 355347.6 Ops/sec
jQuery + getElementById 1448723.4 Ops/sec
jQuery + getElementsByClassName 487193.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


;