Vanilla JS, Cash and jQuery - GetID Speed Test
5 years ago
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0
Test name |
Executions per second |
getElementById() |
935074.2 Ops/sec |
getElementsByClassName() |
952127.3 Ops/sec |
getElementsByTagName() |
875507.8 Ops/sec |
querySelector(#id) |
1027653.0 Ops/sec |
querySelector(.id) |
1015602.0 Ops/sec |
querySelectorAll(#id) |
353552.0 Ops/sec |
querySelectorAll(.id) |
482958.1 Ops/sec |
jQuery(#id) |
859422.3 Ops/sec |
jQuery(.id) |
281481.6 Ops/sec |
jQuery(tag#id) |
112189.6 Ops/sec |
jQuery(tag.id) |
145399.6 Ops/sec |
jQuery + getElementById |
715062.6 Ops/sec |
jQuery + getElementsByClassName |
216675.7 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