Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
Chrome 80
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 2349936.0 Ops/sec
getElementsByClassName() 1435123.5 Ops/sec
getElementsByTagName() 1804797.8 Ops/sec
querySelector(#id) 1300459.0 Ops/sec
querySelector(.id) 2579140.8 Ops/sec
querySelectorAll(#id) 692610.6 Ops/sec
querySelectorAll(.id) 1088772.0 Ops/sec
jQuery(#id) 1082787.4 Ops/sec
jQuery(.id) 371388.4 Ops/sec
jQuery(tag#id) 271798.1 Ops/sec
jQuery(tag.id) 291101.1 Ops/sec
jQuery + getElementById 910841.1 Ops/sec
jQuery + getElementsByClassName 388052.3 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