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() 2535770.8 Ops/sec
getElementsByClassName() 1245611.5 Ops/sec
getElementsByTagName() 1426028.5 Ops/sec
querySelector(#id) 1117371.5 Ops/sec
querySelector(.id) 1550805.9 Ops/sec
querySelectorAll(#id) 426464.8 Ops/sec
querySelectorAll(.id) 489510.5 Ops/sec
jQuery(#id) 521985.2 Ops/sec
jQuery(.id) 245605.0 Ops/sec
jQuery(tag#id) 157598.5 Ops/sec
jQuery(tag.id) 160271.5 Ops/sec
jQuery + getElementById 740550.3 Ops/sec
jQuery + getElementsByClassName 241029.6 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


;