Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
jQuery each vs pure JS
Searching for tagName
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
jQuery
698267.9 Ops/sec
pure JS
1376254.8 Ops/sec
jQuery DIV
705550.1 Ops/sec
pure JS DIV
175.9 Ops/sec
HTML Preparation code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Script Preparation code:
//Add 100,000 elements var frag = document.createDocumentFragment(); for (var i=0; i<10; i++){ var outSection = document.createElement('section'); outSection.id="secid_"+i; for (var j=0; j<100; j++){ var midDiv = document.createElement('div'); midDiv.id="mdivid_"+j; for (var k=0; k<100; k++){ var inDiv = document.createElement('div'); inDiv.id="divid_"+k; midDiv.appendChild(inDiv); } outSection.appendChild(midDiv) } frag.appendChild(outSection); } document.body.appendChild(frag);
Tests:
jQuery
var a = 0; $('section').each(function () { a++; });
pure JS
function forEachElement(selector, fn) { var elements = document.getElementsByTagName(selector); for (var i = 0; i < elements.length; i++) fn(elements[i]); } var a = 0; forEachElement('section', function (el){ a++; });
jQuery DIV
var a = 0; $('section').each(function () { a++; });
pure JS DIV
function forEachElement(selector, fn) { var elements = document.getElementsByTagName(selector); for (var i = 0; i < elements.length; i++) fn(elements[i]); } var a = 0; forEachElement('div', function (el){ a++; });