Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 Kinza/4.8.1
Chrome 67
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 3084922.2 Ops/sec
getElementsByClassName() 2079670.8 Ops/sec
getElementsByTagName() 2426962.8 Ops/sec
querySelector(#id) 1681588.0 Ops/sec
querySelector(.id) 2383537.5 Ops/sec
querySelectorAll(#id) 826004.3 Ops/sec
querySelectorAll(.id) 1039608.6 Ops/sec
jQuery(#id) 1227616.0 Ops/sec
jQuery(.id) 532319.7 Ops/sec
jQuery(tag#id) 296483.2 Ops/sec
jQuery(tag.id) 313132.8 Ops/sec
jQuery + getElementById 1238721.1 Ops/sec
jQuery + getElementsByClassName 441688.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


;