Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Chrome 72
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3470454.5 Ops/sec
getElementsByClassName() 2326379.0 Ops/sec
getElementsByTagName() 2721248.0 Ops/sec
querySelector(#id) 2028550.0 Ops/sec
querySelector(.id) 2806134.2 Ops/sec
querySelectorAll(#id) 722787.9 Ops/sec
querySelectorAll(.id) 827400.5 Ops/sec
jQuery(#id) 1157957.6 Ops/sec
jQuery(.id) 600816.1 Ops/sec
jQuery(tag#id) 312706.8 Ops/sec
jQuery(tag.id) 342222.2 Ops/sec
jQuery + getElementById 1440792.6 Ops/sec
jQuery + getElementsByClassName 567229.1 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