create dom element

JavaScript performance comparison

Test case created by form

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var options = {action: "path"};
   
};

Benchmark.prototype.teardown = function() {
    options = null;
};
</script>

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
one liner
$('<form action="' + options.action + '"></form>');
pending…
var $form
     var $form = $('<form></form>');
     $form.attr('action',options.action);
 
pending…
chain
$('<form></form>').attr('action',options.action)
pending…
native mix
$(document.createElement("form")).attr('action',options.action)
pending…
native
var form = document.createElement("form"),
    $form = $(form);
form.action = options.action;
pending…
another query
$('<form>', {action: options.action})
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment