Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2350113.5 Ops/sec
getElementsByClassName() 2107938.2 Ops/sec
getElementsByTagName() 2393040.8 Ops/sec
querySelector(#id) 2465286.5 Ops/sec
querySelector(.id) 2389238.2 Ops/sec
querySelectorAll(#id) 679956.4 Ops/sec
querySelectorAll(.id) 1076527.4 Ops/sec
jQuery(#id) 2365507.0 Ops/sec
jQuery(.id) 661880.0 Ops/sec
jQuery(tag#id) 330830.9 Ops/sec
jQuery(tag.id) 387325.7 Ops/sec
jQuery + getElementById 1994793.8 Ops/sec
jQuery + getElementsByClassName 544433.4 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


;