Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0
Firefox 50
Windows
Other
8 years ago
Test name Executions per second
getElementById() 11420960.0 Ops/sec
getElementsByClassName() 3974368.5 Ops/sec
getElementsByTagName() 5365296.0 Ops/sec
querySelector(#id) 6086710.5 Ops/sec
querySelector(.id) 471836.6 Ops/sec
querySelectorAll(#id) 1453215.8 Ops/sec
querySelectorAll(.id) 57643.9 Ops/sec
jQuery(#id) 2078947.9 Ops/sec
jQuery(.id) 415361.0 Ops/sec
jQuery(tag#id) 298396.2 Ops/sec
jQuery(tag.id) 45708.9 Ops/sec
jQuery + getElementById 2318443.0 Ops/sec
jQuery + getElementsByClassName 537039.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