<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'></script>
<script>
var $jq1124 = $.noConflict(true);
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
var $jq224 = $.noConflict(true);
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var $jq331 = $.noConflict(true);
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var $jq351 = $.noConflict(true);
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
var $jq360 = $.noConflict(true);
</script>
<div>
<ul id="menu">
<li class="menu-item">1</li>
<li class="menu-item">2</li>
<li class="menu-item">3</li>
<li class="menu-item">4</li>
<li class="menu-item">5</li>
</ul>
</div>
function tests($) {
$(".menu-item").eq(2).closest("ul").css({
"background-color": "red"
}).parent().css({
"border": "1px solid blue"
}).append($("<p></p>").text("Text.").css({
"background-color": "green"
})).end().end().remove();
console.log('tests' + $);
}
tests($jq1124);
tests($jq224);
tests($jq331);
tests($jq351);
tests($jq360);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
$jq1124 | |
$jq224 | |
$jq331 | |
$jq351 | |
$jq360 |
Test name | Executions per second |
---|---|
$jq1124 | 24835.2 Ops/sec |
$jq224 | 34296.2 Ops/sec |
$jq331 | 32920.7 Ops/sec |
$jq351 | 32773.1 Ops/sec |
$jq360 | 31523.5 Ops/sec |
Let's break down the benchmark and its options.
What is being tested?
The benchmark is testing the speed of different versions of jQuery (a popular JavaScript library for DOM manipulation) when used in a specific script. The script is designed to modify an HTML structure, which triggers the execution of jQuery functions.
Options compared:
The benchmark compares the execution speed of six different versions of jQuery:
Pros and Cons of different approaches:
Each version of jQuery has its own strengths and weaknesses:
Libraries used:
None of the benchmark test cases use any external libraries beyond jQuery itself.
Special JavaScript features or syntax:
There are no special JavaScript features or syntax mentioned in the benchmark setup. However, the use of $.noConflict(true)
is a common pattern in jQuery versions 1.9 and above, which helps to prevent conflicts with other libraries that may also use $
.
Alternatives:
If you're looking for alternatives to MeasureThat.net, here are some options:
Keep in mind that each tool has its own strengths and weaknesses, so it's essential to choose the one that best fits your needs.