Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Chrome 76
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 4430759.5 Ops/sec
getElementsByClassName() 2556514.2 Ops/sec
getElementsByTagName() 3173124.8 Ops/sec
querySelector(#id) 2308111.5 Ops/sec
querySelector(.id) 3413591.2 Ops/sec
querySelectorAll(#id) 1147305.1 Ops/sec
querySelectorAll(.id) 1494418.6 Ops/sec
jQuery(#id) 1406512.2 Ops/sec
jQuery(.id) 677445.1 Ops/sec
jQuery(tag#id) 436521.8 Ops/sec
jQuery(tag.id) 461097.1 Ops/sec
jQuery + getElementById 1610099.0 Ops/sec
jQuery + getElementsByClassName 589966.4 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