Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/69.0.3497.81 Chrome/69.0.3497.81 Safari/537.36
Chromium 69
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 3465331.0 Ops/sec
getElementsByClassName() 2462704.5 Ops/sec
getElementsByTagName() 2808531.5 Ops/sec
querySelector(#id) 2081611.8 Ops/sec
querySelector(.id) 2839279.8 Ops/sec
querySelectorAll(#id) 872967.8 Ops/sec
querySelectorAll(.id) 1086477.4 Ops/sec
jQuery(#id) 1226121.6 Ops/sec
jQuery(.id) 658636.1 Ops/sec
jQuery(tag#id) 387999.5 Ops/sec
jQuery(tag.id) 379833.4 Ops/sec
jQuery + getElementById 1457611.9 Ops/sec
jQuery + getElementsByClassName 534516.8 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