Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.80 Chrome/71.0.3578.80 Safari/537.36
Chromium 71
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 3378419.5 Ops/sec
getElementsByClassName() 2254151.0 Ops/sec
getElementsByTagName() 2704269.8 Ops/sec
querySelector(#id) 2154068.0 Ops/sec
querySelector(.id) 2747993.0 Ops/sec
querySelectorAll(#id) 731948.0 Ops/sec
querySelectorAll(.id) 879539.4 Ops/sec
jQuery(#id) 1088652.4 Ops/sec
jQuery(.id) 599076.3 Ops/sec
jQuery(tag#id) 350930.6 Ops/sec
jQuery(tag.id) 369140.9 Ops/sec
jQuery + getElementById 1369673.5 Ops/sec
jQuery + getElementsByClassName 531102.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