Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3218.0 Safari/537.36
Chrome 63
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3003421.5 Ops/sec
getElementsByClassName() 1989592.2 Ops/sec
getElementsByTagName() 1932288.5 Ops/sec
querySelector(#id) 2220614.8 Ops/sec
querySelector(.id) 366497.1 Ops/sec
querySelectorAll(#id) 1029274.1 Ops/sec
querySelectorAll(.id) 55509.4 Ops/sec
jQuery(#id) 939217.8 Ops/sec
jQuery(.id) 508721.8 Ops/sec
jQuery(tag#id) 374717.9 Ops/sec
jQuery(tag.id) 51027.7 Ops/sec
jQuery + getElementById 750401.4 Ops/sec
jQuery + getElementsByClassName 203488.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