Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0
Firefox 63
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 2407628.2 Ops/sec
getElementsByClassName() 2290679.0 Ops/sec
getElementsByTagName() 2755225.8 Ops/sec
querySelector(#id) 2651002.8 Ops/sec
querySelector(.id) 2736921.5 Ops/sec
querySelectorAll(#id) 886406.2 Ops/sec
querySelectorAll(.id) 1331078.1 Ops/sec
jQuery(#id) 2876268.8 Ops/sec
jQuery(.id) 842724.4 Ops/sec
jQuery(tag#id) 416945.5 Ops/sec
jQuery(tag.id) 452739.1 Ops/sec
jQuery + getElementById 2100799.5 Ops/sec
jQuery + getElementsByClassName 670740.9 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