Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
Chrome 87
Windows
Desktop
3 years ago
Test name Executions per second
getElementById 1965626.8 Ops/sec
jQuery (tag.id) 261957.8 Ops/sec
jQuery (tag#id) 280426.4 Ops/sec
jQuery (.id) 389086.6 Ops/sec
jQuery (#id) 1190029.6 Ops/sec
Cash + getElementsByClassName 627272.8 Ops/sec
Cash + getElementById 839423.6 Ops/sec
Cash (tag.id) 324749.8 Ops/sec
jQuery + getElementById 901790.2 Ops/sec
Cash (tag#id) 302447.5 Ops/sec
Cash (#id) 1207038.1 Ops/sec
querySelectorAll (.id) 911084.7 Ops/sec
querySelectorAll (#id) 693749.3 Ops/sec
querySelector (.id) 2080385.1 Ops/sec
querySelector (#id) 1263998.1 Ops/sec
getElementsByTagName 1540568.1 Ops/sec
getElementsByClassName 1352302.6 Ops/sec
Cash (.id) 435917.9 Ops/sec
jQuery + getElementsByClassName 373577.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