Vanilla JS, Cash and jQuery - GetID Speed Test
7 years ago
User agent:
Mozilla/5.0 (Android 6.0.1; Mobile; rv:52.0) Gecko/52.0 Firefox/52.0
Test name |
Executions per second |
getElementById() |
1613547.0 Ops/sec |
getElementsByClassName() |
275721.7 Ops/sec |
getElementsByTagName() |
488182.6 Ops/sec |
querySelector(#id) |
707869.4 Ops/sec |
querySelector(.id) |
48111.4 Ops/sec |
querySelectorAll(#id) |
66561.4 Ops/sec |
querySelectorAll(.id) |
8047.6 Ops/sec |
jQuery(#id) |
295354.4 Ops/sec |
jQuery(.id) |
21938.5 Ops/sec |
jQuery(tag#id) |
15683.5 Ops/sec |
jQuery(tag.id) |
5629.2 Ops/sec |
jQuery + getElementById |
179279.0 Ops/sec |
jQuery + getElementsByClassName |
25897.6 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