Vanilla JS, Cash and jQuery - GetID Speed Test
3 years ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Test name |
Executions per second |
getElementById |
2009311.0 Ops/sec |
jQuery (tag.id) |
163251.3 Ops/sec |
jQuery (tag#id) |
160756.4 Ops/sec |
jQuery (.id) |
206637.3 Ops/sec |
jQuery (#id) |
911632.9 Ops/sec |
Cash + getElementsByClassName |
496443.3 Ops/sec |
Cash + getElementById |
792198.0 Ops/sec |
Cash (tag.id) |
251245.9 Ops/sec |
jQuery + getElementById |
810708.3 Ops/sec |
Cash (tag#id) |
230829.4 Ops/sec |
Cash (#id) |
1125989.0 Ops/sec |
querySelectorAll (.id) |
1102056.0 Ops/sec |
querySelectorAll (#id) |
646877.0 Ops/sec |
querySelector (.id) |
2396675.0 Ops/sec |
querySelector (#id) |
1330798.0 Ops/sec |
getElementsByTagName |
1351245.0 Ops/sec |
getElementsByClassName |
1312558.0 Ops/sec |
Cash (.id) |
274663.4 Ops/sec |
jQuery + getElementsByClassName |
228944.5 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