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() 3400860.2 Ops/sec
getElementsByClassName() 1988318.2 Ops/sec
getElementsByTagName() 2676643.0 Ops/sec
querySelector(#id) 1965946.5 Ops/sec
querySelector(.id) 2645146.0 Ops/sec
querySelectorAll(#id) 992427.8 Ops/sec
querySelectorAll(.id) 1267412.4 Ops/sec
jQuery(#id) 1143671.0 Ops/sec
jQuery(.id) 540456.9 Ops/sec
jQuery(tag#id) 369071.6 Ops/sec
jQuery(tag.id) 376745.7 Ops/sec
jQuery + getElementById 1356510.6 Ops/sec
jQuery + getElementsByClassName 489038.5 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