Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/68.0.3440.106 Chrome/68.0.3440.106 Safari/537.36
Chromium 68
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 3265045.8 Ops/sec
getElementsByClassName() 2346870.8 Ops/sec
getElementsByTagName() 2676545.0 Ops/sec
querySelector(#id) 1979993.5 Ops/sec
querySelector(.id) 2674414.0 Ops/sec
querySelectorAll(#id) 854812.2 Ops/sec
querySelectorAll(.id) 1021120.2 Ops/sec
jQuery(#id) 982123.6 Ops/sec
jQuery(.id) 505500.8 Ops/sec
jQuery(tag#id) 326430.5 Ops/sec
jQuery(tag.id) 333932.5 Ops/sec
jQuery + getElementById 1241364.6 Ops/sec
jQuery + getElementsByClassName 432788.0 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