Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 744091.5 Ops/sec
getElementsByClassName() 517538.4 Ops/sec
getElementsByTagName() 598140.2 Ops/sec
querySelector(#id) 455407.5 Ops/sec
querySelector(.id) 700714.9 Ops/sec
querySelectorAll(#id) 178238.0 Ops/sec
querySelectorAll(.id) 228270.4 Ops/sec
jQuery(#id) 196044.1 Ops/sec
jQuery(.id) 70771.1 Ops/sec
jQuery(tag#id) 42562.8 Ops/sec
jQuery(tag.id) 39862.2 Ops/sec
jQuery + getElementById 248187.7 Ops/sec
jQuery + getElementsByClassName 69130.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


;