Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
Chrome 60
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2328341.0 Ops/sec
getElementsByClassName() 1607464.0 Ops/sec
getElementsByTagName() 1874020.4 Ops/sec
querySelector(#id) 1935252.9 Ops/sec
querySelector(.id) 385366.0 Ops/sec
querySelectorAll(#id) 844509.0 Ops/sec
querySelectorAll(.id) 45561.2 Ops/sec
jQuery(#id) 731630.4 Ops/sec
jQuery(.id) 570025.8 Ops/sec
jQuery(tag#id) 345862.0 Ops/sec
jQuery(tag.id) 49447.7 Ops/sec
jQuery + getElementById 764921.1 Ops/sec
jQuery + getElementsByClassName 306718.8 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


;