Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Mac OS X 10.14.0
Desktop
6 years ago
Test name Executions per second
getElementById() 2785915.8 Ops/sec
getElementsByClassName() 1732224.2 Ops/sec
getElementsByTagName() 2369424.2 Ops/sec
querySelector(#id) 1661930.1 Ops/sec
querySelector(.id) 2057069.5 Ops/sec
querySelectorAll(#id) 605734.9 Ops/sec
querySelectorAll(.id) 811892.1 Ops/sec
jQuery(#id) 635810.5 Ops/sec
jQuery(.id) 252264.4 Ops/sec
jQuery(tag#id) 150409.8 Ops/sec
jQuery(tag.id) 148101.5 Ops/sec
jQuery + getElementById 1014928.9 Ops/sec
jQuery + getElementsByClassName 226455.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


;