Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 2418272.2 Ops/sec
getElementsByClassName() 1781156.9 Ops/sec
getElementsByTagName() 2602270.8 Ops/sec
querySelector(#id) 2030223.5 Ops/sec
querySelector(.id) 2652435.0 Ops/sec
querySelectorAll(#id) 901676.8 Ops/sec
querySelectorAll(.id) 1132345.1 Ops/sec
jQuery(#id) 1021651.6 Ops/sec
jQuery(.id) 455851.8 Ops/sec
jQuery(tag#id) 266151.9 Ops/sec
jQuery(tag.id) 308034.8 Ops/sec
jQuery + getElementById 1367174.2 Ops/sec
jQuery + getElementsByClassName 483535.9 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