Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
Chrome 51
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3468379.8 Ops/sec
getElementsByClassName() 2158829.5 Ops/sec
getElementsByTagName() 1831596.4 Ops/sec
querySelector(#id) 1410271.9 Ops/sec
querySelector(.id) 208700.0 Ops/sec
querySelectorAll(#id) 764898.4 Ops/sec
querySelectorAll(.id) 615596.3 Ops/sec
jQuery(#id) 504423.5 Ops/sec
jQuery(.id) 252671.0 Ops/sec
jQuery(tag#id) 35410.0 Ops/sec
jQuery(tag.id) 30353.3 Ops/sec
jQuery + getElementById 571326.4 Ops/sec
jQuery + getElementsByClassName 231489.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


;