Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2516779.0 Ops/sec
getElementsByClassName() 1662798.5 Ops/sec
getElementsByTagName() 2076254.6 Ops/sec
querySelector(#id) 1406504.2 Ops/sec
querySelector(.id) 2177912.0 Ops/sec
querySelectorAll(#id) 624911.6 Ops/sec
querySelectorAll(.id) 676325.4 Ops/sec
jQuery(#id) 1017060.1 Ops/sec
jQuery(.id) 485050.6 Ops/sec
jQuery(tag#id) 253200.0 Ops/sec
jQuery(tag.id) 284921.3 Ops/sec
jQuery + getElementById 1072708.8 Ops/sec
jQuery + getElementsByClassName 387470.2 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


;