Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Mac OS X 10.11.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3157269.0 Ops/sec
getElementsByClassName() 1757644.6 Ops/sec
getElementsByTagName() 2380384.8 Ops/sec
querySelector(#id) 1777068.0 Ops/sec
querySelector(.id) 2446083.2 Ops/sec
querySelectorAll(#id) 785221.6 Ops/sec
querySelectorAll(.id) 842407.8 Ops/sec
jQuery(#id) 1012220.1 Ops/sec
jQuery(.id) 465786.2 Ops/sec
jQuery(tag#id) 258759.0 Ops/sec
jQuery(tag.id) 273524.3 Ops/sec
jQuery + getElementById 1144530.8 Ops/sec
jQuery + getElementsByClassName 365124.7 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