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() 3649410.0 Ops/sec
getElementsByClassName() 2473115.2 Ops/sec
getElementsByTagName() 3001041.8 Ops/sec
querySelector(#id) 3042165.0 Ops/sec
querySelector(.id) 637111.1 Ops/sec
querySelectorAll(#id) 1386928.6 Ops/sec
querySelectorAll(.id) 110948.7 Ops/sec
jQuery(#id) 1490661.9 Ops/sec
jQuery(.id) 898936.7 Ops/sec
jQuery(tag#id) 511294.4 Ops/sec
jQuery(tag.id) 86384.2 Ops/sec
jQuery + getElementById 1558050.9 Ops/sec
jQuery + getElementsByClassName 510721.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