Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
Chrome 54
Windows 7
Other
8 years ago
Test name Executions per second
getElementById() 2420751.8 Ops/sec
getElementsByClassName() 1689881.6 Ops/sec
getElementsByTagName() 2094754.0 Ops/sec
querySelector(#id) 1956522.2 Ops/sec
querySelector(.id) 563999.9 Ops/sec
querySelectorAll(#id) 869807.8 Ops/sec
querySelectorAll(.id) 91630.3 Ops/sec
jQuery(#id) 824950.1 Ops/sec
jQuery(.id) 372935.9 Ops/sec
jQuery(tag#id) 237263.3 Ops/sec
jQuery(tag.id) 60451.3 Ops/sec
jQuery + getElementById 958903.8 Ops/sec
jQuery + getElementsByClassName 211924.2 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