Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Windows 7
Desktop
4 years ago
Test name Executions per second
getElementById() 2521811.0 Ops/sec
getElementsByClassName() 1278424.0 Ops/sec
getElementsByTagName() 1864840.1 Ops/sec
querySelector(#id) 2107582.8 Ops/sec
querySelector(.id) 2090958.5 Ops/sec
querySelectorAll(#id) 610312.4 Ops/sec
querySelectorAll(.id) 692298.8 Ops/sec
jQuery(#id) 2950166.5 Ops/sec
jQuery(.id) 532097.2 Ops/sec
jQuery(tag#id) 236155.2 Ops/sec
jQuery(tag.id) 242268.2 Ops/sec
jQuery + getElementById 1807131.1 Ops/sec
jQuery + getElementsByClassName 428458.4 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