Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2851194.0 Ops/sec
getElementsByClassName() 1773457.2 Ops/sec
getElementsByTagName() 2279715.5 Ops/sec
querySelector(#id) 1585062.5 Ops/sec
querySelector(.id) 2223091.2 Ops/sec
querySelectorAll(#id) 762003.9 Ops/sec
querySelectorAll(.id) 1012245.1 Ops/sec
jQuery(#id) 938246.9 Ops/sec
jQuery(.id) 438588.0 Ops/sec
jQuery(tag#id) 293484.8 Ops/sec
jQuery(tag.id) 301654.8 Ops/sec
jQuery + getElementById 1098125.9 Ops/sec
jQuery + getElementsByClassName 381150.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