Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Mac OS X 10.14.0
Desktop
5 years ago
Test name Executions per second
getElementById() 3319378.2 Ops/sec
getElementsByClassName() 2029204.1 Ops/sec
getElementsByTagName() 2459454.2 Ops/sec
querySelector(#id) 1764495.2 Ops/sec
querySelector(.id) 2570782.2 Ops/sec
querySelectorAll(#id) 673352.4 Ops/sec
querySelectorAll(.id) 890870.6 Ops/sec
jQuery(#id) 1083827.2 Ops/sec
jQuery(.id) 458611.4 Ops/sec
jQuery(tag#id) 288971.2 Ops/sec
jQuery(tag.id) 304895.0 Ops/sec
jQuery + getElementById 1287860.2 Ops/sec
jQuery + getElementsByClassName 473911.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