Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
Chrome 67
Mac OS X 10.12.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3795918.0 Ops/sec
getElementsByClassName() 2334643.5 Ops/sec
getElementsByTagName() 3101564.0 Ops/sec
querySelector(#id) 2271126.5 Ops/sec
querySelector(.id) 3222541.5 Ops/sec
querySelectorAll(#id) 974083.8 Ops/sec
querySelectorAll(.id) 1124442.5 Ops/sec
jQuery(#id) 1262179.5 Ops/sec
jQuery(.id) 581037.6 Ops/sec
jQuery(tag#id) 345642.2 Ops/sec
jQuery(tag.id) 344920.7 Ops/sec
jQuery + getElementById 1280704.8 Ops/sec
jQuery + getElementsByClassName 442400.6 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


;