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() 3095328.2 Ops/sec
getElementsByClassName() 1733916.4 Ops/sec
getElementsByTagName() 2476699.0 Ops/sec
querySelector(#id) 1678323.4 Ops/sec
querySelector(.id) 2512549.0 Ops/sec
querySelectorAll(#id) 714419.8 Ops/sec
querySelectorAll(.id) 907787.4 Ops/sec
jQuery(#id) 1048506.0 Ops/sec
jQuery(.id) 491346.0 Ops/sec
jQuery(tag#id) 287457.1 Ops/sec
jQuery(tag.id) 288020.8 Ops/sec
jQuery + getElementById 1188582.1 Ops/sec
jQuery + getElementsByClassName 396942.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