Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Chrome 63
Windows 7
Other
2025 years ago
Test name Executions per second
getElementById() 2296677.5 Ops/sec
getElementsByClassName() 1475035.9 Ops/sec
getElementsByTagName() 1594778.5 Ops/sec
querySelector(#id) 1564924.5 Ops/sec
querySelector(.id) 421283.2 Ops/sec
querySelectorAll(#id) 717709.6 Ops/sec
querySelectorAll(.id) 62713.3 Ops/sec
jQuery(#id) 620943.0 Ops/sec
jQuery(.id) 264880.4 Ops/sec
jQuery(tag#id) 182883.0 Ops/sec
jQuery(tag.id) 42399.5 Ops/sec
jQuery + getElementById 808884.6 Ops/sec
jQuery + getElementsByClassName 207039.9 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


;