Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2896275.2 Ops/sec
getElementsByClassName() 1685575.1 Ops/sec
getElementsByTagName() 2318043.8 Ops/sec
querySelector(#id) 1726362.6 Ops/sec
querySelector(.id) 2367552.5 Ops/sec
querySelectorAll(#id) 594282.8 Ops/sec
querySelectorAll(.id) 673586.2 Ops/sec
jQuery(#id) 975896.2 Ops/sec
jQuery(.id) 481843.4 Ops/sec
jQuery(tag#id) 247372.7 Ops/sec
jQuery(tag.id) 257557.1 Ops/sec
jQuery + getElementById 1119841.1 Ops/sec
jQuery + getElementsByClassName 454329.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


;