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() 2073392.1 Ops/sec
getElementsByClassName() 1356421.5 Ops/sec
getElementsByTagName() 1626212.8 Ops/sec
querySelector(#id) 1264794.5 Ops/sec
querySelector(.id) 1688208.0 Ops/sec
querySelectorAll(#id) 527299.6 Ops/sec
querySelectorAll(.id) 662965.1 Ops/sec
jQuery(#id) 555992.6 Ops/sec
jQuery(.id) 177543.5 Ops/sec
jQuery(tag#id) 109553.0 Ops/sec
jQuery(tag.id) 109274.5 Ops/sec
jQuery + getElementById 628677.9 Ops/sec
jQuery + getElementsByClassName 190766.7 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


;