Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.11.2 Chrome/65.0.3325.230 Safari/537.36
Chrome 65
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2519067.0 Ops/sec
getElementsByClassName() 1743087.0 Ops/sec
getElementsByTagName() 1994591.4 Ops/sec
querySelector(#id) 1521089.1 Ops/sec
querySelector(.id) 1987657.1 Ops/sec
querySelectorAll(#id) 705391.9 Ops/sec
querySelectorAll(.id) 868379.3 Ops/sec
jQuery(#id) 1018980.1 Ops/sec
jQuery(.id) 435668.8 Ops/sec
jQuery(tag#id) 254054.7 Ops/sec
jQuery(tag.id) 267184.7 Ops/sec
jQuery + getElementById 1016211.1 Ops/sec
jQuery + getElementsByClassName 439378.1 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