Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Chrome 61
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3072824.0 Ops/sec
getElementsByClassName() 2115828.2 Ops/sec
getElementsByTagName() 2584827.8 Ops/sec
querySelector(#id) 2534142.8 Ops/sec
querySelector(.id) 550384.0 Ops/sec
querySelectorAll(#id) 1049976.8 Ops/sec
querySelectorAll(.id) 89560.0 Ops/sec
jQuery(#id) 1212752.4 Ops/sec
jQuery(.id) 720034.3 Ops/sec
jQuery(tag#id) 411157.7 Ops/sec
jQuery(tag.id) 73727.7 Ops/sec
jQuery + getElementById 1207572.9 Ops/sec
jQuery + getElementsByClassName 390956.2 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


;