Vanilla JS, Cash and jQuery - GetID Speed Test
7 years ago
User agent:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Test name |
Executions per second |
getElementById() |
2711205.0 Ops/sec |
getElementsByClassName() |
1975134.0 Ops/sec |
getElementsByTagName() |
2311532.0 Ops/sec |
querySelector(#id) |
2244596.0 Ops/sec |
querySelector(.id) |
668057.4 Ops/sec |
querySelectorAll(#id) |
1076226.0 Ops/sec |
querySelectorAll(.id) |
106578.6 Ops/sec |
jQuery(#id) |
1249595.0 Ops/sec |
jQuery(.id) |
739423.4 Ops/sec |
jQuery(tag#id) |
427771.9 Ops/sec |
jQuery(tag.id) |
80919.0 Ops/sec |
jQuery + getElementById |
1228796.0 Ops/sec |
jQuery + getElementsByClassName |
402941.3 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