Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
forEach vs for vs Query each
(version: 0)
with <link>
Comparing performance of:
forEach (Native) vs for (Native) vs each (jQuery)
Created:
9 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css">
Tests:
forEach (Native)
var linkEls = document.querySelectorAll('link[href*=".min.css"]'); [].forEach.call(linkEls,function(el){ console.log(el); });
for (Native)
var linkEls = $('.class'); for(var i = 0; i < linkEls.length; i++) { var el = linkEls[i]; console.log(el); }
each (jQuery)
$('link[href*=".min.css"]').each(function(){ console.log(this); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
forEach (Native)
for (Native)
each (jQuery)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Browser/OS:
Chrome 140 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
forEach (Native)
128992.4 Ops/sec
for (Native)
5266079.5 Ops/sec
each (jQuery)
95644.3 Ops/sec
Related benchmarks:
forEach vs jQuery each
forEach vs for vs Query each
forEach vs for vs Query each vs for of
forEach vs jQuery each vs for-of
Comments
Confirm delete:
Do you really want to delete benchmark?