Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Chrome 63
Windows
Other
2025 years ago
Test name Executions per second
getElementById() 2894121.2 Ops/sec
getElementsByClassName() 1739950.4 Ops/sec
getElementsByTagName() 1634801.2 Ops/sec
querySelector(#id) 1838038.9 Ops/sec
querySelector(.id) 421124.1 Ops/sec
querySelectorAll(#id) 931508.1 Ops/sec
querySelectorAll(.id) 78358.2 Ops/sec
jQuery(#id) 813019.9 Ops/sec
jQuery(.id) 416243.3 Ops/sec
jQuery(tag#id) 233333.3 Ops/sec
jQuery(tag.id) 48392.0 Ops/sec
jQuery + getElementById 1013779.1 Ops/sec
jQuery + getElementsByClassName 273105.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