Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2494785.0 Ops/sec
getElementsByClassName() 1674684.1 Ops/sec
getElementsByTagName() 1949013.1 Ops/sec
querySelector(#id) 1640228.0 Ops/sec
querySelector(.id) 2110255.8 Ops/sec
querySelectorAll(#id) 693476.2 Ops/sec
querySelectorAll(.id) 817050.1 Ops/sec
jQuery(#id) 921627.1 Ops/sec
jQuery(.id) 451992.6 Ops/sec
jQuery(tag#id) 225736.1 Ops/sec
jQuery(tag.id) 255377.1 Ops/sec
jQuery + getElementById 1032539.6 Ops/sec
jQuery + getElementsByClassName 395788.7 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


;