Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2744033.0 Ops/sec
getElementsByClassName() 1789346.0 Ops/sec
getElementsByTagName() 2056703.8 Ops/sec
querySelector(#id) 1738650.9 Ops/sec
querySelector(.id) 2306343.8 Ops/sec
querySelectorAll(#id) 803942.4 Ops/sec
querySelectorAll(.id) 965297.6 Ops/sec
jQuery(#id) 932741.7 Ops/sec
jQuery(.id) 455134.3 Ops/sec
jQuery(tag#id) 260337.3 Ops/sec
jQuery(tag.id) 283017.3 Ops/sec
jQuery + getElementById 1063252.0 Ops/sec
jQuery + getElementsByClassName 335654.0 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


;