Run details:
Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0
Firefox 52
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 9211793.0 Ops/sec
getElementsByClassName() 3453864.5 Ops/sec
getElementsByTagName() 5428622.0 Ops/sec
querySelector(#id) 3012004.8 Ops/sec
querySelector(.id) 2866756.0 Ops/sec
querySelectorAll(#id) 892763.6 Ops/sec
querySelectorAll(.id) 914223.2 Ops/sec
jQuery(#id) 4647649.5 Ops/sec
jQuery(.id) 386754.8 Ops/sec
jQuery(tag#id) 219002.8 Ops/sec
jQuery(tag.id) 217389.6 Ops/sec
jQuery + getElementById 5632771.0 Ops/sec
jQuery + getElementsByClassName 484361.9 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