Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Firefox 60
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2194255.2 Ops/sec
getElementsByClassName() 1960360.9 Ops/sec
getElementsByTagName() 2330733.5 Ops/sec
querySelector(#id) 2512604.8 Ops/sec
querySelector(.id) 2296309.2 Ops/sec
querySelectorAll(#id) 683807.0 Ops/sec
querySelectorAll(.id) 1071842.6 Ops/sec
jQuery(#id) 2341079.5 Ops/sec
jQuery(.id) 707731.1 Ops/sec
jQuery(tag#id) 361581.3 Ops/sec
jQuery(tag.id) 416429.0 Ops/sec
jQuery + getElementById 1866565.0 Ops/sec
jQuery + getElementsByClassName 566629.1 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