Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1870521.0 Ops/sec
getElementsByClassName() 1097630.5 Ops/sec
getElementsByTagName() 1381318.5 Ops/sec
querySelector(#id) 1118472.4 Ops/sec
querySelector(.id) 1587295.6 Ops/sec
querySelectorAll(#id) 434368.8 Ops/sec
querySelectorAll(.id) 518498.8 Ops/sec
jQuery(#id) 444158.0 Ops/sec
jQuery(.id) 193510.3 Ops/sec
jQuery(tag#id) 118040.4 Ops/sec
jQuery(tag.id) 127239.4 Ops/sec
jQuery + getElementById 721899.5 Ops/sec
jQuery + getElementsByClassName 191811.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