Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1072528.2 Ops/sec
getElementsByClassName() 706985.5 Ops/sec
getElementsByTagName() 780141.8 Ops/sec
querySelector(#id) 695565.4 Ops/sec
querySelector(.id) 914238.1 Ops/sec
querySelectorAll(#id) 348823.6 Ops/sec
querySelectorAll(.id) 433746.7 Ops/sec
jQuery(#id) 338744.3 Ops/sec
jQuery(.id) 178482.8 Ops/sec
jQuery(tag#id) 107963.1 Ops/sec
jQuery(tag.id) 113935.1 Ops/sec
jQuery + getElementById 415644.5 Ops/sec
jQuery + getElementsByClassName 145077.1 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