SO - 23019682

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id='1'>
    <div class="template">
        <div>
            <label class="right inline">Response:</label>
        </div>
        <div>
            <input type="text" name="responseText[]" value="" maxlength="400" />
        </div>
        <div>
            <input type="radio" name="responseRadio[]" value="" />
        </div>
    </div>
    <div>
        <input type="button" name="addNewRow" value="Add Row" />
        <input type="button" name="removeRow" value="Remove Row" />
    </div>
</div>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Zword
var $template = $('.template');
$('input[name=addNewRow]').click(function() {
    $template.clone().insertAfter($template).find("input:text").val("");
});
$('input[name=removeRow]').click(function() {
    $('.template').get(-1).outerHTML = "";
});
pending…
T J
var $template = $('.template');
$('#add').click(function() { // where add is the id of add button
 $template.clone().insertAfter($template).find("input:text").val("");
});
$('#remove').click(function() { // where remove is the id of remove button
if($('.template').length>1)
 $('.template').last().remove();
});
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