Vanilla JS, Cash and jQuery - GetID Speed Test
7 months ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Test name |
Executions per second |
getElementById |
11050680.0 Ops/sec |
jQuery (tag.id) |
1585707.0 Ops/sec |
jQuery (tag#id) |
1411619.0 Ops/sec |
jQuery (.id) |
2631563.0 Ops/sec |
jQuery (#id) |
4627566.0 Ops/sec |
Cash + getElementsByClassName |
2929756.0 Ops/sec |
Cash + getElementById |
4495168.0 Ops/sec |
Cash (tag.id) |
2309698.0 Ops/sec |
jQuery + getElementById |
5006051.0 Ops/sec |
Cash (tag#id) |
1932335.0 Ops/sec |
Cash (#id) |
5040012.0 Ops/sec |
querySelectorAll (.id) |
3045331.0 Ops/sec |
querySelectorAll (#id) |
2679044.0 Ops/sec |
querySelector (.id) |
6098784.0 Ops/sec |
querySelector (#id) |
4262769.0 Ops/sec |
getElementsByTagName |
8326467.0 Ops/sec |
getElementsByClassName |
6958162.0 Ops/sec |
Cash (.id) |
3034542.0 Ops/sec |
jQuery + getElementsByClassName |
1746163.0 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