Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 4584300.5 Ops/sec
getElementsByClassName() 2768833.2 Ops/sec
getElementsByTagName() 3573025.8 Ops/sec
querySelector(#id) 2536362.2 Ops/sec
querySelector(.id) 3681708.0 Ops/sec
querySelectorAll(#id) 1023253.6 Ops/sec
querySelectorAll(.id) 1281439.8 Ops/sec
jQuery(#id) 1404026.1 Ops/sec
jQuery(.id) 703160.9 Ops/sec
jQuery(tag#id) 409107.0 Ops/sec
jQuery(tag.id) 419720.2 Ops/sec
jQuery + getElementById 1663313.2 Ops/sec
jQuery + getElementsByClassName 641785.6 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