Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Chrome 56
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2068769.5 Ops/sec
getElementsByClassName() 1728493.2 Ops/sec
getElementsByTagName() 2014327.6 Ops/sec
querySelector(#id) 1447309.1 Ops/sec
querySelector(.id) 410749.6 Ops/sec
querySelectorAll(#id) 895437.4 Ops/sec
querySelectorAll(.id) 65484.5 Ops/sec
jQuery(#id) 668724.4 Ops/sec
jQuery(.id) 385741.2 Ops/sec
jQuery(tag#id) 264758.6 Ops/sec
jQuery(tag.id) 49673.7 Ops/sec
jQuery + getElementById 758927.1 Ops/sec
jQuery + getElementsByClassName 355271.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


;