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 OPR/65.0.3467.78
Opera 65
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 4305641.5 Ops/sec
getElementsByClassName() 2564337.0 Ops/sec
getElementsByTagName() 3288803.2 Ops/sec
querySelector(#id) 2423482.2 Ops/sec
querySelector(.id) 3161169.2 Ops/sec
querySelectorAll(#id) 1147551.6 Ops/sec
querySelectorAll(.id) 1443015.1 Ops/sec
jQuery(#id) 1357586.0 Ops/sec
jQuery(.id) 571009.3 Ops/sec
jQuery(tag#id) 370339.6 Ops/sec
jQuery(tag.id) 371834.1 Ops/sec
jQuery + getElementById 1540004.4 Ops/sec
jQuery + getElementsByClassName 562289.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


;