Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Mac OS X 10.13.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3373424.0 Ops/sec
getElementsByClassName() 2161284.8 Ops/sec
getElementsByTagName() 2720732.0 Ops/sec
querySelector(#id) 1955976.4 Ops/sec
querySelector(.id) 2749864.2 Ops/sec
querySelectorAll(#id) 787368.9 Ops/sec
querySelectorAll(.id) 1042613.1 Ops/sec
jQuery(#id) 1236412.5 Ops/sec
jQuery(.id) 568021.1 Ops/sec
jQuery(tag#id) 286940.9 Ops/sec
jQuery(tag.id) 315638.1 Ops/sec
jQuery + getElementById 1181694.4 Ops/sec
jQuery + getElementsByClassName 472837.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


;