Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Mac OS X 10.15.1
Desktop
5 years ago
Test name Executions per second
getElementById() 5906811.5 Ops/sec
getElementsByClassName() 3444580.2 Ops/sec
getElementsByTagName() 4352245.0 Ops/sec
querySelector(#id) 2877432.8 Ops/sec
querySelector(.id) 4234788.5 Ops/sec
querySelectorAll(#id) 1438358.9 Ops/sec
querySelectorAll(.id) 1901900.4 Ops/sec
jQuery(#id) 1598506.9 Ops/sec
jQuery(.id) 778570.5 Ops/sec
jQuery(tag#id) 526857.1 Ops/sec
jQuery(tag.id) 558853.0 Ops/sec
jQuery + getElementById 1858074.1 Ops/sec
jQuery + getElementsByClassName 703960.2 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