JQuery Tmpl as string (v2)

Revision 2 of this benchmark created on


Description

Checking performance of the tmpl plugin when outputting as a string rather than a DOM object

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
</script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
<script id="personTmpl" type="text/x-jquery-tmpl">
<li><span>${name}</span><span>${jobTitle}</span></li>
</script>

Setup

var somedata = [
            { name: "PersonA", jobTitle:"JobTitleA" },
            { name: "PersonB", jobTitle:"JobTitleB" }
        ];
    
    var tmplFn = $( "#personTmpl" ).template();

Test runner

Ready to run.

Testing in
TestOps/sec
tmpl as string
var result = $.map( somedata, function( item ) {
        return tmplFn( $, { data: item } );
    }).join("");
ready
tmpl as DOM
var html = $("#personTmpl").tmpl(somedata)
ready

Revisions

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