Vanilla JS, Cash and jQuery - GetID Speed Test

3 years ago
User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Edg/94.0.992.31
Test name Executions per second
getElementById 3919246.0 Ops/sec
jQuery (tag.id) 551489.9 Ops/sec
jQuery (tag#id) 513348.2 Ops/sec
jQuery (.id) 755304.3 Ops/sec
jQuery (#id) 2021269.0 Ops/sec
Cash + getElementsByClassName 1149216.0 Ops/sec
Cash + getElementById 1501227.0 Ops/sec
Cash (tag.id) 823884.0 Ops/sec
jQuery + getElementById 1555713.0 Ops/sec
Cash (tag#id) 690566.1 Ops/sec
Cash (#id) 2266583.0 Ops/sec
querySelectorAll (.id) 1996989.0 Ops/sec
querySelectorAll (#id) 1152495.0 Ops/sec
querySelector (.id) 3829652.0 Ops/sec
querySelector (#id) 2126264.0 Ops/sec
getElementsByTagName 3297809.0 Ops/sec
getElementsByClassName 2734306.0 Ops/sec
Cash (.id) 982901.5 Ops/sec
jQuery + getElementsByClassName 668948.1 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

Open this result on MeasureThat.net