Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1972355.6 Ops/sec
getElementsByClassName() 1174643.1 Ops/sec
getElementsByTagName() 1364760.8 Ops/sec
querySelector(#id) 1184938.1 Ops/sec
querySelector(.id) 1627405.6 Ops/sec
querySelectorAll(#id) 495791.3 Ops/sec
querySelectorAll(.id) 556854.3 Ops/sec
jQuery(#id) 396207.8 Ops/sec
jQuery(.id) 187576.8 Ops/sec
jQuery(tag#id) 122503.5 Ops/sec
jQuery(tag.id) 117282.0 Ops/sec
jQuery + getElementById 635074.2 Ops/sec
jQuery + getElementsByClassName 187695.5 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


;