Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3833321.5 Ops/sec
getElementsByClassName() 2288361.5 Ops/sec
getElementsByTagName() 2999245.8 Ops/sec
querySelector(#id) 2181700.0 Ops/sec
querySelector(.id) 3044930.0 Ops/sec
querySelectorAll(#id) 907630.2 Ops/sec
querySelectorAll(.id) 1153524.4 Ops/sec
jQuery(#id) 1157794.6 Ops/sec
jQuery(.id) 591517.8 Ops/sec
jQuery(tag#id) 363032.1 Ops/sec
jQuery(tag.id) 391543.2 Ops/sec
jQuery + getElementById 1276236.6 Ops/sec
jQuery + getElementsByClassName 478381.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