Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Chrome 72
Mac OS X 10.14.3
Desktop
5 years ago
Test name Executions per second
getElementById() 4143486.0 Ops/sec
getElementsByClassName() 2524034.8 Ops/sec
getElementsByTagName() 3047846.2 Ops/sec
querySelector(#id) 2171166.8 Ops/sec
querySelector(.id) 3357595.0 Ops/sec
querySelectorAll(#id) 825397.9 Ops/sec
querySelectorAll(.id) 1114931.4 Ops/sec
jQuery(#id) 1288506.9 Ops/sec
jQuery(.id) 663758.6 Ops/sec
jQuery(tag#id) 359204.1 Ops/sec
jQuery(tag.id) 387134.0 Ops/sec
jQuery + getElementById 1596847.0 Ops/sec
jQuery + getElementsByClassName 618880.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