Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.105 Safari/537.36 Vivaldi/2.4.1488.38
Chrome 73
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1958996.9 Ops/sec
getElementsByClassName() 1256112.8 Ops/sec
getElementsByTagName() 1574552.4 Ops/sec
querySelector(#id) 1162282.9 Ops/sec
querySelector(.id) 1593285.8 Ops/sec
querySelectorAll(#id) 515308.6 Ops/sec
querySelectorAll(.id) 633411.4 Ops/sec
jQuery(#id) 630344.6 Ops/sec
jQuery(.id) 360917.9 Ops/sec
jQuery(tag#id) 191860.6 Ops/sec
jQuery(tag.id) 202535.7 Ops/sec
jQuery + getElementById 760028.9 Ops/sec
jQuery + getElementsByClassName 291788.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