Vanilla JS, Cash and jQuery - GetID Speed Test
5 years ago
User agent:
Mozilla/5.0 (Linux; Android 8.1.0; Aquaris X Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36
Test name |
Executions per second |
getElementById() |
570755.9 Ops/sec |
getElementsByClassName() |
380588.2 Ops/sec |
getElementsByTagName() |
438391.0 Ops/sec |
querySelector(#id) |
279406.1 Ops/sec |
querySelector(.id) |
389662.2 Ops/sec |
querySelectorAll(#id) |
164120.9 Ops/sec |
querySelectorAll(.id) |
198124.4 Ops/sec |
jQuery(#id) |
195911.5 Ops/sec |
jQuery(.id) |
112253.3 Ops/sec |
jQuery(tag#id) |
64295.1 Ops/sec |
jQuery(tag.id) |
66197.2 Ops/sec |
jQuery + getElementById |
242933.5 Ops/sec |
jQuery + getElementsByClassName |
100311.8 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