Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Firefox 54
Windows 7
Other
7 years ago
Test name Executions per second
getElementById() 6244399.5 Ops/sec
getElementsByClassName() 2368854.8 Ops/sec
getElementsByTagName() 3241337.2 Ops/sec
querySelector(#id) 3228925.2 Ops/sec
querySelector(.id) 277274.6 Ops/sec
querySelectorAll(#id) 939618.0 Ops/sec
querySelectorAll(.id) 28592.0 Ops/sec
jQuery(#id) 835745.2 Ops/sec
jQuery(.id) 451007.5 Ops/sec
jQuery(tag#id) 326045.3 Ops/sec
jQuery(tag.id) 28317.2 Ops/sec
jQuery + getElementById 1070551.4 Ops/sec
jQuery + getElementsByClassName 263617.0 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


;