Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
Chrome 67
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 3271255.2 Ops/sec
getElementsByClassName() 2069169.4 Ops/sec
getElementsByTagName() 2607476.0 Ops/sec
querySelector(#id) 2032939.8 Ops/sec
querySelector(.id) 2675921.2 Ops/sec
querySelectorAll(#id) 945595.0 Ops/sec
querySelectorAll(.id) 1150383.6 Ops/sec
jQuery(#id) 1249609.8 Ops/sec
jQuery(.id) 544104.5 Ops/sec
jQuery(tag#id) 337303.5 Ops/sec
jQuery(tag.id) 336385.6 Ops/sec
jQuery + getElementById 1311483.6 Ops/sec
jQuery + getElementsByClassName 428927.2 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


;