Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 3704545.0 Ops/sec
getElementsByClassName() 2590561.2 Ops/sec
getElementsByTagName() 3104683.2 Ops/sec
querySelector(#id) 2384959.5 Ops/sec
querySelector(.id) 3092823.2 Ops/sec
querySelectorAll(#id) 1111202.9 Ops/sec
querySelectorAll(.id) 1420110.0 Ops/sec
jQuery(#id) 1582981.0 Ops/sec
jQuery(.id) 721137.3 Ops/sec
jQuery(tag#id) 399000.7 Ops/sec
jQuery(tag.id) 406183.0 Ops/sec
jQuery + getElementById 1553474.0 Ops/sec
jQuery + getElementsByClassName 578663.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


;