Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Chrome 57
Mac OS X 10.12.4
Other
7 years ago
Test name Executions per second
getElementById() 3043622.2 Ops/sec
getElementsByClassName() 2107950.0 Ops/sec
getElementsByTagName() 2417269.2 Ops/sec
querySelector(#id) 2398846.8 Ops/sec
querySelector(.id) 705042.5 Ops/sec
querySelectorAll(#id) 1112381.1 Ops/sec
querySelectorAll(.id) 86636.4 Ops/sec
jQuery(#id) 1056903.6 Ops/sec
jQuery(.id) 555563.0 Ops/sec
jQuery(tag#id) 366846.6 Ops/sec
jQuery(tag.id) 63066.8 Ops/sec
jQuery + getElementById 1148869.0 Ops/sec
jQuery + getElementsByClassName 383792.0 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