Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
Firefox 68
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2193948.5 Ops/sec
getElementsByClassName() 1795374.4 Ops/sec
getElementsByTagName() 2403534.8 Ops/sec
querySelector(#id) 2299985.0 Ops/sec
querySelector(.id) 2353573.8 Ops/sec
querySelectorAll(#id) 810118.6 Ops/sec
querySelectorAll(.id) 949577.4 Ops/sec
jQuery(#id) 2361916.5 Ops/sec
jQuery(.id) 709871.9 Ops/sec
jQuery(tag#id) 323151.8 Ops/sec
jQuery(tag.id) 409647.1 Ops/sec
jQuery + getElementById 1627147.6 Ops/sec
jQuery + getElementsByClassName 635960.8 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