Run details:
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 YaBrowser/19.4.3.370 Yowser/2.5 Safari/537.36
Yandex Browser 19
Windows 8.1
Desktop
5 years ago
Test name Executions per second
getElementById() 567481.4 Ops/sec
getElementsByClassName() 342086.5 Ops/sec
getElementsByTagName() 424709.9 Ops/sec
querySelector(#id) 353832.5 Ops/sec
querySelector(.id) 461474.7 Ops/sec
querySelectorAll(#id) 153563.6 Ops/sec
querySelectorAll(.id) 167097.4 Ops/sec
jQuery(#id) 146699.2 Ops/sec
jQuery(.id) 89122.7 Ops/sec
jQuery(tag#id) 54840.7 Ops/sec
jQuery(tag.id) 54271.1 Ops/sec
jQuery + getElementById 215797.4 Ops/sec
jQuery + getElementsByClassName 72138.3 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


;