Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
Firefox 67
Ubuntu
Desktop
5 years ago
Test name Executions per second
getElementById() 2248109.2 Ops/sec
getElementsByClassName() 1906929.8 Ops/sec
getElementsByTagName() 2709587.8 Ops/sec
querySelector(#id) 2738168.0 Ops/sec
querySelector(.id) 2781735.2 Ops/sec
querySelectorAll(#id) 1059301.0 Ops/sec
querySelectorAll(.id) 1160951.2 Ops/sec
jQuery(#id) 2563601.5 Ops/sec
jQuery(.id) 752574.8 Ops/sec
jQuery(tag#id) 440460.0 Ops/sec
jQuery(tag.id) 446780.9 Ops/sec
jQuery + getElementById 1740012.2 Ops/sec
jQuery + getElementsByClassName 604466.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