jquery-wrapped this in each

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div class="test">
    <div class="sup">sup</div>
    <div class="plz">plz</div>
</div>
<div class="test">
    <div class="sup">sup</div>
    <div class="plz">plz</div>
</div>
<div class="test">
    <div class="sup">sup</div>
    <div class="plz">plz</div>
</div>
<script>
Benchmark.prototype.setup = function() {
    var $elements = $('.test');
};
</script>

Preparation code output

sup
plz
sup
plz
sup
plz

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jquery-wrapped this all the time
$elements.each(function() {
    var $sup = $(this).children('.sup');
    $sup.html('');
    var $plz = $(this).children('.plz');
    $plz.html('');
});
pending…
jquery-wrapped this once
$elements.each(function() {
    var $this = $(this);
    var $sup = $this.children('.sup');
    $sup.html('');
    var $plz = $this.children('.plz');
    $plz.html('');
});
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment