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.76 Safari/537.36 OPR/43.0.2442.806
Test name |
Executions per second |
getElementById() |
3113828.0 Ops/sec |
getElementsByClassName() |
2127334.0 Ops/sec |
getElementsByTagName() |
2657505.0 Ops/sec |
querySelector(#id) |
2549671.0 Ops/sec |
querySelector(.id) |
610304.1 Ops/sec |
querySelectorAll(#id) |
1256413.0 Ops/sec |
querySelectorAll(.id) |
111650.2 Ops/sec |
jQuery(#id) |
1199227.0 Ops/sec |
jQuery(.id) |
809597.4 Ops/sec |
jQuery(tag#id) |
515033.8 Ops/sec |
jQuery(tag.id) |
90405.9 Ops/sec |
jQuery + getElementById |
1374547.0 Ops/sec |
jQuery + getElementsByClassName |
442921.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