Vanilla JS, Cash and jQuery - GetID Speed Test
5 years ago
User agent:
Mozilla/5.0 (Linux; Android 9; STF-L09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.143 Mobile Safari/537.36
Test name |
Executions per second |
getElementById() |
1198946.0 Ops/sec |
getElementsByClassName() |
844766.2 Ops/sec |
getElementsByTagName() |
965000.6 Ops/sec |
querySelector(#id) |
767416.6 Ops/sec |
querySelector(.id) |
881794.2 Ops/sec |
querySelectorAll(#id) |
418472.3 Ops/sec |
querySelectorAll(.id) |
516219.5 Ops/sec |
jQuery(#id) |
493476.4 Ops/sec |
jQuery(.id) |
298431.8 Ops/sec |
jQuery(tag#id) |
181463.8 Ops/sec |
jQuery(tag.id) |
174297.3 Ops/sec |
jQuery + getElementById |
548821.7 Ops/sec |
jQuery + getElementsByClassName |
221863.4 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