Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome 87
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 2440371.8 Ops/sec
jQuery (tag.id) 314743.8 Ops/sec
jQuery (tag#id) 292483.1 Ops/sec
jQuery (.id) 411892.8 Ops/sec
jQuery (#id) 1110976.6 Ops/sec
Cash + getElementsByClassName 708229.4 Ops/sec
Cash + getElementById 933376.9 Ops/sec
Cash (tag.id) 374897.7 Ops/sec
jQuery + getElementById 1006253.9 Ops/sec
Cash (tag#id) 339894.1 Ops/sec
Cash (#id) 1425099.8 Ops/sec
querySelectorAll (.id) 1096801.8 Ops/sec
querySelectorAll (#id) 781497.6 Ops/sec
querySelector (.id) 2394113.5 Ops/sec
querySelector (#id) 1448295.6 Ops/sec
getElementsByTagName 1859476.2 Ops/sec
getElementsByClassName 1498010.4 Ops/sec
Cash (.id) 485624.2 Ops/sec
jQuery + getElementsByClassName 424724.5 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