Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Safari537.36
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1874966.8 Ops/sec
getElementsByClassName() 1310724.0 Ops/sec
getElementsByTagName() 1800017.6 Ops/sec
querySelector(#id) 1046893.6 Ops/sec
querySelector(.id) 1118608.0 Ops/sec
querySelectorAll(#id) 566344.3 Ops/sec
querySelectorAll(.id) 634234.6 Ops/sec
jQuery(#id) 673622.7 Ops/sec
jQuery(.id) 338059.0 Ops/sec
jQuery(tag#id) 210299.0 Ops/sec
jQuery(tag.id) 186538.0 Ops/sec
jQuery + getElementById 821763.1 Ops/sec
jQuery + getElementsByClassName 219707.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