Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Mac OS X 10.13.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3453429.8 Ops/sec
getElementsByClassName() 2150711.0 Ops/sec
getElementsByTagName() 2756727.2 Ops/sec
querySelector(#id) 1983881.1 Ops/sec
querySelector(.id) 2872231.2 Ops/sec
querySelectorAll(#id) 863231.4 Ops/sec
querySelectorAll(.id) 1157963.6 Ops/sec
jQuery(#id) 1216985.1 Ops/sec
jQuery(.id) 527744.6 Ops/sec
jQuery(tag#id) 318743.5 Ops/sec
jQuery(tag.id) 325178.4 Ops/sec
jQuery + getElementById 1222620.8 Ops/sec
jQuery + getElementsByClassName 426515.0 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


;