jQuery element creation (v13)

Revision 13 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
With trailing slash
$('<div class="hello" onclick="alert(1)" style="color:red;"/>');
ready
Without trailing slash
$('<div class="hello" onclick="alert(1)" style="color:red;">');
ready
Opening and closing tags
$('<div class="hello" onclick="alert(1)" style="color:red;"></div>');
ready
document.createElement
$(document.createElement('div')).attr('class','hello').attr('onclick','alert(1)').attr('style','color:red;');
ready
another create
$("<div/>", { class: "hello", onclick: "alert(1)", style: "color:red" });
ready
yet another
$(document.createElement('div'), { class: "hello", onclick: "alert(1)", style: "color:red" });
ready

Revisions

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