Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0
Firefox 63
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 1181062.0 Ops/sec
getElementsByClassName() 1232760.0 Ops/sec
getElementsByTagName() 1176569.6 Ops/sec
querySelector(#id) 1173982.6 Ops/sec
querySelector(.id) 1301144.1 Ops/sec
querySelectorAll(#id) 401184.2 Ops/sec
querySelectorAll(.id) 529928.1 Ops/sec
jQuery(#id) 1235642.6 Ops/sec
jQuery(.id) 267860.6 Ops/sec
jQuery(tag#id) 107150.0 Ops/sec
jQuery(tag.id) 121823.3 Ops/sec
jQuery + getElementById 1002758.1 Ops/sec
jQuery + getElementsByClassName 333482.9 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