jQuery vs createElement + classes + content

JavaScript performance comparison

Revision 102 of this test case created by allihov

Preparation code

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

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$('<div>')
var d = $('<div class="rating-point active">&#9733;</div>')
pending…
createElement + Html
var d = $(document.createElement('div'));
d.addClass('rating-point active').html('&#9733;');
pending…
createElement + text
var d = $(document.createElement('div'));
d.addClass('rating-point active').text('&#9733;');
pending…
createElement + js content
var d = $(document.createElement('div')
.appendChild(document.createTextNode('&#9733;')));
d.addClass('rating-point active');
pending…
full JS
var d = $(document.createElement('div')
.appendChild(document.createTextNode('&#9733;'))
.className = 'rating-point active');
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