Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Chrome 62
Windows 7
Other
2025 years ago
Test name Executions per second
getElementById() 2219643.5 Ops/sec
getElementsByClassName() 1231401.9 Ops/sec
getElementsByTagName() 1685418.9 Ops/sec
querySelector(#id) 1571352.5 Ops/sec
querySelector(.id) 401655.8 Ops/sec
querySelectorAll(#id) 856430.2 Ops/sec
querySelectorAll(.id) 69325.2 Ops/sec
jQuery(#id) 788753.0 Ops/sec
jQuery(.id) 532883.4 Ops/sec
jQuery(tag#id) 340757.4 Ops/sec
jQuery(tag.id) 57130.7 Ops/sec
jQuery + getElementById 955774.3 Ops/sec
jQuery + getElementsByClassName 310082.8 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


;