Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3310354.5 Ops/sec
getElementsByClassName() 2043215.0 Ops/sec
getElementsByTagName() 2543216.8 Ops/sec
querySelector(#id) 1952583.2 Ops/sec
querySelector(.id) 2551004.8 Ops/sec
querySelectorAll(#id) 799233.3 Ops/sec
querySelectorAll(.id) 969905.6 Ops/sec
jQuery(#id) 1024208.9 Ops/sec
jQuery(.id) 506592.0 Ops/sec
jQuery(tag#id) 334277.8 Ops/sec
jQuery(tag.id) 349236.7 Ops/sec
jQuery + getElementById 1262889.9 Ops/sec
jQuery + getElementsByClassName 519368.6 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


;