Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3748497.8 Ops/sec
getElementsByClassName() 2321300.2 Ops/sec
getElementsByTagName() 2873176.8 Ops/sec
querySelector(#id) 1747844.6 Ops/sec
querySelector(.id) 2452837.2 Ops/sec
querySelectorAll(#id) 835681.1 Ops/sec
querySelectorAll(.id) 1072380.4 Ops/sec
jQuery(#id) 663462.1 Ops/sec
jQuery(.id) 260361.1 Ops/sec
jQuery(tag#id) 195815.2 Ops/sec
jQuery(tag.id) 194196.0 Ops/sec
jQuery + getElementById 1089146.5 Ops/sec
jQuery + getElementsByClassName 300124.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