Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2238085.5 Ops/sec
getElementsByClassName() 1855345.1 Ops/sec
getElementsByTagName() 2322710.5 Ops/sec
querySelector(#id) 1855897.0 Ops/sec
querySelector(.id) 2391512.5 Ops/sec
querySelectorAll(#id) 840140.9 Ops/sec
querySelectorAll(.id) 1038889.1 Ops/sec
jQuery(#id) 1197250.8 Ops/sec
jQuery(.id) 489460.4 Ops/sec
jQuery(tag#id) 307381.3 Ops/sec
jQuery(tag.id) 309014.0 Ops/sec
jQuery + getElementById 1262285.0 Ops/sec
jQuery + getElementsByClassName 427005.6 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