Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
Chrome 78
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 5191958.5 Ops/sec
getElementsByClassName() 3165815.2 Ops/sec
getElementsByTagName() 3887008.0 Ops/sec
querySelector(#id) 2524091.5 Ops/sec
querySelector(.id) 3597213.0 Ops/sec
querySelectorAll(#id) 1356823.4 Ops/sec
querySelectorAll(.id) 1861950.8 Ops/sec
jQuery(#id) 1520698.4 Ops/sec
jQuery(.id) 763160.4 Ops/sec
jQuery(tag#id) 497998.9 Ops/sec
jQuery(tag.id) 524239.9 Ops/sec
jQuery + getElementById 1961444.4 Ops/sec
jQuery + getElementsByClassName 688620.7 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