Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36
Chrome 59
Mac OS X 10.12.5
Other
7 years ago
Test name Executions per second
getElementById() 1348788.0 Ops/sec
getElementsByClassName() 986733.7 Ops/sec
getElementsByTagName() 1012414.2 Ops/sec
querySelector(#id) 1158225.4 Ops/sec
querySelector(.id) 366209.3 Ops/sec
querySelectorAll(#id) 403966.7 Ops/sec
querySelectorAll(.id) 52558.0 Ops/sec
jQuery(#id) 316689.8 Ops/sec
jQuery(.id) 195519.3 Ops/sec
jQuery(tag#id) 111929.3 Ops/sec
jQuery(tag.id) 32437.3 Ops/sec
jQuery + getElementById 555501.9 Ops/sec
jQuery + getElementsByClassName 133216.4 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


;