Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Firefox 49
Windows 7
Other
8 years ago
Test name Executions per second
getElementById() 8013997.5 Ops/sec
getElementsByClassName() 2771031.2 Ops/sec
getElementsByTagName() 3815250.5 Ops/sec
querySelector(#id) 4181035.8 Ops/sec
querySelector(.id) 372095.2 Ops/sec
querySelectorAll(#id) 1157002.1 Ops/sec
querySelectorAll(.id) 46851.2 Ops/sec
jQuery(#id) 1624828.1 Ops/sec
jQuery(.id) 377600.1 Ops/sec
jQuery(tag#id) 274935.6 Ops/sec
jQuery(tag.id) 47062.9 Ops/sec
jQuery + getElementById 4994609.5 Ops/sec
jQuery + getElementsByClassName 534859.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