Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2312668.5 Ops/sec
getElementsByClassName() 1532707.5 Ops/sec
getElementsByTagName() 1881331.5 Ops/sec
querySelector(#id) 1327753.0 Ops/sec
querySelector(.id) 1862071.0 Ops/sec
querySelectorAll(#id) 637606.5 Ops/sec
querySelectorAll(.id) 770332.1 Ops/sec
jQuery(#id) 919675.8 Ops/sec
jQuery(.id) 387837.7 Ops/sec
jQuery(tag#id) 226458.7 Ops/sec
jQuery(tag.id) 238200.3 Ops/sec
jQuery + getElementById 867160.2 Ops/sec
jQuery + getElementsByClassName 294554.4 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


;