Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Chrome 66
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3243738.2 Ops/sec
getElementsByClassName() 2135070.2 Ops/sec
getElementsByTagName() 2640676.8 Ops/sec
querySelector(#id) 1877913.5 Ops/sec
querySelector(.id) 2683051.8 Ops/sec
querySelectorAll(#id) 807152.6 Ops/sec
querySelectorAll(.id) 1012569.1 Ops/sec
jQuery(#id) 1191825.0 Ops/sec
jQuery(.id) 560100.4 Ops/sec
jQuery(tag#id) 307456.0 Ops/sec
jQuery(tag.id) 331162.1 Ops/sec
jQuery + getElementById 1270636.2 Ops/sec
jQuery + getElementsByClassName 500315.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