Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0
Firefox 82
Ubuntu
Desktop
4 years ago
Test name Executions per second
getElementById 2151921.5 Ops/sec
jQuery (tag.id) 319788.7 Ops/sec
jQuery (tag#id) 301331.2 Ops/sec
jQuery (.id) 511646.1 Ops/sec
jQuery (#id) 3051511.8 Ops/sec
Cash + getElementsByClassName 898261.5 Ops/sec
Cash + getElementById 1669088.2 Ops/sec
Cash (tag.id) 597821.9 Ops/sec
jQuery + getElementById 1783950.0 Ops/sec
Cash (tag#id) 563196.8 Ops/sec
Cash (#id) 3369278.8 Ops/sec
querySelectorAll (.id) 789102.3 Ops/sec
querySelectorAll (#id) 727056.0 Ops/sec
querySelector (.id) 1963424.8 Ops/sec
querySelector (#id) 1984452.9 Ops/sec
getElementsByTagName 1955286.2 Ops/sec
getElementsByClassName 1321464.6 Ops/sec
Cash (.id) 1013712.7 Ops/sec
jQuery + getElementsByClassName 451454.7 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