Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Chrome 77
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 4539410.0 Ops/sec
getElementsByClassName() 2639810.0 Ops/sec
getElementsByTagName() 2572577.0 Ops/sec
querySelector(#id) 2439532.2 Ops/sec
querySelector(.id) 3595059.5 Ops/sec
querySelectorAll(#id) 1189210.5 Ops/sec
querySelectorAll(.id) 1625133.2 Ops/sec
jQuery(#id) 1457625.9 Ops/sec
jQuery(.id) 726169.6 Ops/sec
jQuery(tag#id) 461547.8 Ops/sec
jQuery(tag.id) 448794.2 Ops/sec
jQuery + getElementById 1717048.8 Ops/sec
jQuery + getElementsByClassName 609735.8 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


;