Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 4962186.0 Ops/sec
getElementsByClassName() 3082768.8 Ops/sec
getElementsByTagName() 3706474.0 Ops/sec
querySelector(#id) 2463269.2 Ops/sec
querySelector(.id) 3504857.0 Ops/sec
querySelectorAll(#id) 987388.8 Ops/sec
querySelectorAll(.id) 1219989.1 Ops/sec
jQuery(#id) 1457704.5 Ops/sec
jQuery(.id) 753445.8 Ops/sec
jQuery(tag#id) 398174.9 Ops/sec
jQuery(tag.id) 430884.7 Ops/sec
jQuery + getElementById 1709332.9 Ops/sec
jQuery + getElementsByClassName 570083.4 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


;