Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
Chrome 62
Windows 7
Other
7 years ago
Test name Executions per second
getElementById() 2770530.0 Ops/sec
getElementsByClassName() 1835713.1 Ops/sec
getElementsByTagName() 1886333.8 Ops/sec
querySelector(#id) 2151244.0 Ops/sec
querySelector(.id) 534047.6 Ops/sec
querySelectorAll(#id) 875318.0 Ops/sec
querySelectorAll(.id) 87745.4 Ops/sec
jQuery(#id) 734160.0 Ops/sec
jQuery(.id) 345353.7 Ops/sec
jQuery(tag#id) 227884.9 Ops/sec
jQuery(tag.id) 58032.6 Ops/sec
jQuery + getElementById 974310.8 Ops/sec
jQuery + getElementsByClassName 235714.3 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