Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
Firefox 59
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 3159407.0 Ops/sec
getElementsByClassName() 2604960.5 Ops/sec
getElementsByTagName() 3387330.2 Ops/sec
querySelector(#id) 2364568.0 Ops/sec
querySelector(.id) 2322508.8 Ops/sec
querySelectorAll(#id) 901033.5 Ops/sec
querySelectorAll(.id) 917713.0 Ops/sec
jQuery(#id) 2902002.8 Ops/sec
jQuery(.id) 730028.1 Ops/sec
jQuery(tag#id) 478589.5 Ops/sec
jQuery(tag.id) 453934.3 Ops/sec
jQuery + getElementById 2544162.8 Ops/sec
jQuery + getElementsByClassName 712941.2 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