Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3010820.8 Ops/sec
getElementsByClassName() 1798185.1 Ops/sec
getElementsByTagName() 2388647.2 Ops/sec
querySelector(#id) 1736994.8 Ops/sec
querySelector(.id) 2319110.5 Ops/sec
querySelectorAll(#id) 870852.4 Ops/sec
querySelectorAll(.id) 1065936.0 Ops/sec
jQuery(#id) 974240.6 Ops/sec
jQuery(.id) 449522.3 Ops/sec
jQuery(tag#id) 299145.1 Ops/sec
jQuery(tag.id) 276087.7 Ops/sec
jQuery + getElementById 1091766.5 Ops/sec
jQuery + getElementsByClassName 407369.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