Vanilla JS, Cash and jQuery - GetID Speed Test
5 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Test name |
Executions per second |
getElementById() |
3755638.5 Ops/sec |
getElementsByClassName() |
2257772.8 Ops/sec |
getElementsByTagName() |
2797873.2 Ops/sec |
querySelector(#id) |
1947718.1 Ops/sec |
querySelector(.id) |
2835510.5 Ops/sec |
querySelectorAll(#id) |
639868.8 Ops/sec |
querySelectorAll(.id) |
968211.6 Ops/sec |
jQuery(#id) |
1188193.4 Ops/sec |
jQuery(.id) |
582711.8 Ops/sec |
jQuery(tag#id) |
312237.9 Ops/sec |
jQuery(tag.id) |
351344.2 Ops/sec |
jQuery + getElementById |
1316526.9 Ops/sec |
jQuery + getElementsByClassName |
553074.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