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() 1913751.9 Ops/sec
getElementsByClassName() 1286739.9 Ops/sec
getElementsByTagName() 1374241.6 Ops/sec
querySelector(#id) 1354971.0 Ops/sec
querySelector(.id) 389407.5 Ops/sec
querySelectorAll(#id) 706379.6 Ops/sec
querySelectorAll(.id) 59284.1 Ops/sec
jQuery(#id) 552026.5 Ops/sec
jQuery(.id) 234491.7 Ops/sec
jQuery(tag#id) 160784.7 Ops/sec
jQuery(tag.id) 36699.9 Ops/sec
jQuery + getElementById 708112.5 Ops/sec
jQuery + getElementsByClassName 185258.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