Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_2) AppleWebKit/603.1.13 (KHTML, like Gecko) Version/11.0.2 Safari/603.1.13
Safari 11
Mac OS X 11.0.2
Desktop
6 years ago
Test name Executions per second
getElementById() 2509552.8 Ops/sec
getElementsByClassName() 2217975.2 Ops/sec
getElementsByTagName() 2649115.8 Ops/sec
querySelector(#id) 2624990.0 Ops/sec
querySelector(.id) 2548843.0 Ops/sec
querySelectorAll(#id) 767908.0 Ops/sec
querySelectorAll(.id) 1041583.6 Ops/sec
jQuery(#id) 2614199.5 Ops/sec
jQuery(.id) 796847.1 Ops/sec
jQuery(tag#id) 397736.1 Ops/sec
jQuery(tag.id) 451851.8 Ops/sec
jQuery + getElementById 2209059.0 Ops/sec
jQuery + getElementsByClassName 611862.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


;