Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763
Edge 18.17763
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2692982.5 Ops/sec
getElementsByClassName() 1764759.0 Ops/sec
getElementsByTagName() 1755116.6 Ops/sec
querySelector(#id) 1491878.8 Ops/sec
querySelector(.id) 800690.9 Ops/sec
querySelectorAll(#id) 705281.7 Ops/sec
querySelectorAll(.id) 515370.2 Ops/sec
jQuery(#id) 552445.4 Ops/sec
jQuery(.id) 356134.3 Ops/sec
jQuery(tag#id) 163942.4 Ops/sec
jQuery(tag.id) 153826.5 Ops/sec
jQuery + getElementById 545462.5 Ops/sec
jQuery + getElementsByClassName 253967.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


;