Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3483.0 Safari/537.36
Chrome 69
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 3255092.2 Ops/sec
getElementsByClassName() 1916227.1 Ops/sec
getElementsByTagName() 2564728.2 Ops/sec
querySelector(#id) 1966565.2 Ops/sec
querySelector(.id) 2597686.8 Ops/sec
querySelectorAll(#id) 759939.4 Ops/sec
querySelectorAll(.id) 1001753.4 Ops/sec
jQuery(#id) 1222638.2 Ops/sec
jQuery(.id) 519311.7 Ops/sec
jQuery(tag#id) 299804.7 Ops/sec
jQuery(tag.id) 312292.9 Ops/sec
jQuery + getElementById 1254319.0 Ops/sec
jQuery + getElementsByClassName 451522.6 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