Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Chrome 72
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1410310.0 Ops/sec
getElementsByClassName() 900309.4 Ops/sec
getElementsByTagName() 1195452.8 Ops/sec
querySelector(#id) 824251.4 Ops/sec
querySelector(.id) 1285231.4 Ops/sec
querySelectorAll(#id) 283883.3 Ops/sec
querySelectorAll(.id) 356629.4 Ops/sec
jQuery(#id) 363894.6 Ops/sec
jQuery(.id) 136239.3 Ops/sec
jQuery(tag#id) 68974.0 Ops/sec
jQuery(tag.id) 96387.1 Ops/sec
jQuery + getElementById 586464.8 Ops/sec
jQuery + getElementsByClassName 177967.5 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


;