Vanilla JS, Cash and jQuery - GetID Speed Test
4 years ago
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Test name |
Executions per second |
getElementById |
2695674.0 Ops/sec |
jQuery (tag.id) |
394946.2 Ops/sec |
jQuery (tag#id) |
384762.0 Ops/sec |
jQuery (.id) |
538409.4 Ops/sec |
jQuery (#id) |
1465605.0 Ops/sec |
Cash + getElementsByClassName |
861356.6 Ops/sec |
Cash + getElementById |
1258395.0 Ops/sec |
Cash (tag.id) |
537568.4 Ops/sec |
jQuery + getElementById |
1265896.0 Ops/sec |
Cash (tag#id) |
477006.8 Ops/sec |
Cash (#id) |
1686067.0 Ops/sec |
querySelectorAll (.id) |
1489508.0 Ops/sec |
querySelectorAll (#id) |
1027551.0 Ops/sec |
querySelector (.id) |
3036069.0 Ops/sec |
querySelector (#id) |
1783811.0 Ops/sec |
getElementsByTagName |
1992749.0 Ops/sec |
getElementsByClassName |
1791949.0 Ops/sec |
Cash (.id) |
616566.9 Ops/sec |
jQuery + getElementsByClassName |
488665.8 Ops/sec |
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
Open this result on MeasureThat.net