Vanilla JS, Cash and jQuery - GetID Speed Test
10 months ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Test name |
Executions per second |
getElementById |
5937618.0 Ops/sec |
jQuery (tag.id) |
675554.8 Ops/sec |
jQuery (tag#id) |
637422.6 Ops/sec |
jQuery (.id) |
988241.3 Ops/sec |
jQuery (#id) |
1698441.0 Ops/sec |
Cash + getElementsByClassName |
1121480.0 Ops/sec |
Cash + getElementById |
1935462.0 Ops/sec |
Cash (tag.id) |
1128925.0 Ops/sec |
jQuery + getElementById |
2234398.0 Ops/sec |
Cash (tag#id) |
858026.3 Ops/sec |
Cash (#id) |
2237567.0 Ops/sec |
querySelectorAll (.id) |
2161398.0 Ops/sec |
querySelectorAll (#id) |
1321688.0 Ops/sec |
querySelector (.id) |
3819016.0 Ops/sec |
querySelector (#id) |
2348441.0 Ops/sec |
getElementsByTagName |
4295844.0 Ops/sec |
getElementsByClassName |
3371754.0 Ops/sec |
Cash (.id) |
1221618.0 Ops/sec |
jQuery + getElementsByClassName |
702764.1 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