Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36
Chrome 66
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 2446194.2 Ops/sec
getElementsByClassName() 1606883.5 Ops/sec
getElementsByTagName() 1972063.8 Ops/sec
querySelector(#id) 1422997.2 Ops/sec
querySelector(.id) 1944999.9 Ops/sec
querySelectorAll(#id) 600559.4 Ops/sec
querySelectorAll(.id) 753079.4 Ops/sec
jQuery(#id) 842983.4 Ops/sec
jQuery(.id) 396290.6 Ops/sec
jQuery(tag#id) 221482.3 Ops/sec
jQuery(tag.id) 221120.2 Ops/sec
jQuery + getElementById 938886.1 Ops/sec
jQuery + getElementsByClassName 330436.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