Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 OPR/55.0.2994.61
Opera 55
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3279283.2 Ops/sec
getElementsByClassName() 2089575.6 Ops/sec
getElementsByTagName() 2567052.8 Ops/sec
querySelector(#id) 1834595.0 Ops/sec
querySelector(.id) 2616086.2 Ops/sec
querySelectorAll(#id) 813666.5 Ops/sec
querySelectorAll(.id) 939766.1 Ops/sec
jQuery(#id) 1158512.1 Ops/sec
jQuery(.id) 476651.7 Ops/sec
jQuery(tag#id) 263757.9 Ops/sec
jQuery(tag.id) 272937.0 Ops/sec
jQuery + getElementById 1222608.9 Ops/sec
jQuery + getElementsByClassName 397301.3 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