JavaScript template language shootoff
JavaScript performance comparison
Info
A brief comparison of some JavaScript templating engines on a short template: 6 header tags, and 10 list items.
Since the purpose is to generate HTML for the DOM, the tests now include DOM node creation.
(JUP templates were removed, because they produced incorrect output and are incapable of producing the desired output from a template and the given data.)
Preparation code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://leonidas.github.com/transparency/js/transparency.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script src="https://github.com/downloads/paul/handlebars.js/handlebars.js"></script>
<script src="http://gist.github.com/raw/550881/29bb186167079c0b33ab6e9d50d779f37860cfa4/micro.js"></script>
<script src="http://github.com/creationix/haml-js/raw/master/lib/haml.js"></script>
<script src="http://gist.github.com/raw/550723/12d176698628e30a1df398c7ac7aea93924e1294/jade.js"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
<script src="http://sstephenson.github.com/eco/dist/eco.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="https://github.com/olado/doT/raw/master/doT.js"></script>
<script src="https://github.com/olado/doT/raw/master/doU.js"></script>
<script src="http://github.com/aefxx/jQote2/raw/69b2053a13f5f180e696de9b3dba856a3c00678c/jquery.jqote2.js"></script>
<script src="https://raw.github.com/relativityboy/Orange-J/master/jquery.orange.js"></script>
<script type='text/javascript'>
// hogan looks for exports and smashes it's contents :(
var oldExports = exports;
exports = undefined;
</script>
<script src="//twitter.github.com/hogan.js/builds/1.0.5/hogan-1.0.5.js"></script>
<script type='text/javascript'>
exports = oldExports;
</script>
<div id="transparency_template">
<h1 class='header'></h1>
<h2 class='header2'></h2>
<h3 class='header3'></h3>
<h4 class='header4'></h4>
<h5 class='header5'></h5>
<h6 class='header6'></h6>
<ul class='list'>
<li class='item'></li>
</ul>
</div>
<script>
window.transparencyTemplate = document.getElementById("transparency_template")
transparencyTemplate.parentNode.removeChild(transparencyTemplate);
window.mustacheTemplate = "<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#list}}<li class='item'>{{.}}</li>{{/list}}</ul></div>";
window.handlebarsTemplate = Handlebars.compile("<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#list}}<li class='item'>{{this}}</li>{{/list}}</ul></div>");
window.micro = "<div><h1 class='header'><%= header %></h1><h2 class='header2'><%= header2 %></h2><h3 class='header3'><%= header3 %></h3><h4 class='header4'><%= header4 %></h4><h5 class='header5'><%= header5 %></h5><h6 class='header6'><%= header6 %></h6><ul class='list'><% for (var i = 0, l = list.length; i < l; i++) { %><li class='item'><%= list[i] %></li><% } %></ul></div>";
window.underscoreTemplate = _.template(micro);
window.resigTemplate = tmpl(micro);
window.sharedVariables = {
header: "Header",
header2: "Header2",
header3: "Header3",
header4: "Header4",
header5: "Header5",
header6: "Header6",
list: ['10000000', '2', '3', '4', '5', '6', '7', '8', '9', '10']
};
window.jadeTemplate = "div\n h1.header!= header\n h2.header2!= header2\n h3.header3!= header3\n h4.header4!= header4\n h5.header5!= header5\n h6.header6!= header6\n ul.list\n - each item in list\n li.item!= item";
window.hamlTemplate = Haml("%div\n %h1.header= header\n %h2.header2= header2\n %h3.header3= header3\n %h4.header4= header4\n %h5.header5= header5\n %h6.header6= header6\n %ul.list\n :each item in list\n %li.item= item");
window.ecoTemplate = eco("<div><h1 class='header'><%- @header %></h1><h2 class='header2'><%- @header2 %></h2><h3 class='header3'><%- @header3 %></h3><h4 class='header4'><%- @header4 %></h4><h5 class='header5'><%- @header5 %></h5><h6 class='header6'><%- @header6 %></h6><ul class='list'><% for item in @list: %><li class='item'><%- item %></li><% end %></ul></div>");
window.jQueryTemplate = $.template(null, "<div><h1 class='header'>${header}</h1><h2 class='header2'>${header2}</h2><h3 class='header3'>${header3}</h3><h4 class='header4'>${header4}</h4><h5 class='header5'>${header5}</h5><h6 class='header6'>${header6}</h6><ul class='list'>{{each list}}<li class='item'>${$value}</li>{{/each}}</ul></div>");
window.doTtemplate = doT.template("<div><h1 class='header'>{{= it.header }}</h1><h2 class='header2'>{{= it.header2 }}</h2><h3 class='header3'>{{= it.header3 }}</h3><h4 class='header4'>{{= it.header4 }}</h4><h5 class='header5'>{{= it.header5 }}</h5><h6 class='header6'>{{= it.header6 }}</h6><ul class='list'>{{ for (var i = 0, l = it.list.length; i < l; i++) { }}<li class='item'>{{= it.list[i] }}</li>{{ } }}</ul></div>");
window.doUtemplate = doU.template("<div><h1 class='header'>{{= it.header }}</h1><h2 class='header2'>{{= it.header2 }}</h2><h3 class='header3'>{{= it.header3 }}</h3><h4 class='header4'>{{= it.header4 }}</h4><h5 class='header5'>{{= it.header5 }}</h5><h6 class='header6'>{{= it.header6 }}</h6><ul class='list'>{{ for (var i = 0, l = it.list.length; i < l; i++) { }}<li class='item'>{{= it.list[i] }}</li>{{ } }}</ul></div>");
window.jqote_tmpl = "<div><h1 class='header'><%= this.header %></h1><h2 class='header2'><%= this.header2 %></h2><h3 class='header3'><%= this.header3 %></h3><h4 class='header4'><%= this.header4 %></h4><h5 class='header5'><%= this.header5 %></h5><h6 class='header6'><%= this.header6 %></h6><ul class='list'><% for (var n = 0, l = this.list.length; n < l; n++) { %><li class='item'><%= this.list[n] %></li><% } %></ul></div>";
window.jqote2 = $.jqotec(jqote_tmpl);
$.addSnippet("test1", "<div><h1 class='header'>{header}</h1><h2 class='header2'>{header2}</h2><h3 class='header3'>{header3}</h3><h4 class='header4'>{header4}</h4><h5 class='header5'>{header5}</h5><h6 class='header6'>{header6}</h6><ul class='list'>{list[]}<li class='item'>{val}</li>{[]list}</ul></div>");
window.hoganTemplate = Hogan.compile("<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#list}}<li class='item'>{{.}}</li>{{/list}}</ul></div>");
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Mustache.js Template |
|
pending… |
Resig Micro-Templating. |
|
pending… |
Creationix's Haml-js Template |
|
pending… |
Jade Template |
|
pending… |
Underscore.js Template |
|
pending… |
Eco Template |
|
pending… |
jQuery Templates |
|
pending… |
Handlebars.js |
|
pending… |
doT.js |
|
pending… |
doU.js |
|
pending… |
jQote2 direct |
|
pending… |
Orange-J |
|
pending… |
Twitter's Hogan.js |
|
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:
- Revision 1: published by Jeremy Ashkenas
- Revision 3: published by Jeremy Ashkenas
- Revision 6: published
- Revision 7: published by bradleymeck
- Revision 8: published
- Revision 9: published by Jeremy Ashkenas
- Revision 11: published by Sam Stephenson
- Revision 13: published by Sam Stephenson
- Revision 14: published by bradleymeck
- Revision 15: published by Jeremy Ashkenas
- Revision 17: published by Jeremy Ashkenas
- Revision 20: published by Sam Stephenson
- Revision 22: published by Jeremy Ashkenas
- Revision 25: published by Carlos Killpack
- Revision 28: published by aefxx
- Revision 30: published by GregWa
- Revision 32: published by Carlos Killpack
- Revision 33: published by Schuyler D
- Revision 42: published by Schuyler D
- Revision 44: published by Schuyler D
- Revision 45: published by Jeremy Ashkenas
- Revision 47: published by Paul Sadauskas
- Revision 48: published by Yehuda Katz
- Revision 52: published by Laura Doktorova
- Revision 53: published by Laura Doktorova
- Revision 55: published by Jacob Chapel
- Revision 56: published by Jacob Chapel
- Revision 57: published by Mic
- Revision 59: published by Jeremy Ashkenas
- Revision 62: published by Jacob Chapel
- Revision 63: published by Jeremy Ashkenas
- Revision 64: published
- Revision 67: published by Jeremy Ashkenas
- Revision 70: published
- Revision 73: published by Jeremy Ashkenas
- Revision 76: published by Michael Paul
- Revision 77: published by Heitor Salazar Baldelli
- Revision 78: published by aefxx
- Revision 79: published by aefxx
- Revision 80: published by Marijn
- Revision 81: published by Manu
- Revision 82: published
- Revision 83: published by Boris Moore
- Revision 84: published by Jörn Zaefferer
- Revision 85: published by tsvetomir
- Revision 88: published by VasiliyS
- Revision 89: published by AndrewF
- Revision 90: published by Atanas Korchev
- Revision 91: published
- Revision 92: published
- Revision 94: published by tsvetomir
- Revision 95: published by AndrewF
- Revision 96: published by AndrewF
- Revision 97: published by foo
- Revision 99: published by AndrewF
- Revision 100: published by pvande
- Revision 103: published by Andrew Petersen
- Revision 104: published
- Revision 105: published by Premasagar Rose
- Revision 106: published by tmpvar
- Revision 111: published by Premasagar Rose
- Revision 112: published by Jeremy Ashkenas
- Revision 113: published
- Revision 114: published by Johann Chiang
- Revision 115: published
- Revision 117: published
- Revision 118: published by AndrewF
- Revision 120: published
- Revision 121: published
- Revision 128: published
- Revision 131: published
- Revision 133: published by Joel Hughes
- Revision 135: published by Arxisos
- Revision 136: published by Murmeli
- Revision 137: published by Murmeli
- Revision 138: published
- Revision 139: published by QLeelulu
- Revision 142: published by QLeelulu
- Revision 143: published by QLeelulu
- Revision 144: published by Shaun
- Revision 146: published by Schuyler D
- Revision 153: published by Andrew Petersen
- Revision 154: published
- Revision 155: published
- Revision 156: published by Tim Farland
- Revision 157: published by Kevin Decker
- Revision 159: published by Lloyd Cotten
- Revision 160: published by Daniel Lindsley
- Revision 162: published by Esteban Corrales
- Revision 163: published by Boris Moore
- Revision 164: published
- Revision 165: published by ben
- Revision 166: published by ben
- Revision 168: published by Sacah
- Revision 172: published by gt
- Revision 173: published
- Revision 174: published by rwb
- Revision 175: published by Joel 'Rudenoise' Hughes
- Revision 177: published by payload
- Revision 179: published
- Revision 180: published
- Revision 181: published
- Revision 182: published
- Revision 183: published
- Revision 184: published
- Revision 185: published
- Revision 187: published by EB
- Revision 188: published
- Revision 189: published by Todd Anglin
- Revision 190: published
- Revision 191: published by Chris Kihneman
- Revision 192: published by Chris Kihneman
- Revision 193: published
- Revision 194: published
- Revision 195: published
- Revision 196: published
- Revision 197: published by flo
- Revision 198: published
- Revision 199: published
- Revision 200: published by Todd Anglin
- Revision 201: published by Laura Doktorova
- Revision 202: published
- Revision 204: published by Todd Anglin
- Revision 205: published by Dave Tonge
- Revision 207: published by Vijayakrishna
- Revision 208: published by Vijayakrishna
- Revision 209: published
- Revision 210: published by Refael Ackermann
- Revision 211: published by Nate Cavanaugh and last updated
- Revision 214: published by Laura Doktorova
- Revision 215: published
- Revision 217: published by Todd Anglin
- Revision 231: published
- Revision 233: published by Jaap Dunnebier
- Revision 234: published by Mihai Bazon and last updated
- Revision 243: published
- Revision 244: published by jsPop
- Revision 245: published by jsPop
- Revision 246: published
- Revision 247: published by Nate Cavanaugh
- Revision 249: published by Garrick
- Revision 250: published
- Revision 253: published
- Revision 254: published by Lance Pollard
- Revision 256: published by jsPop
- Revision 257: published
- Revision 258: published by jsPop
- Revision 259: published by jsPop
- Revision 261: published by Robert Oswald
- Revision 264: published by Chris Dickinson
- Revision 265: published by Chris Dickinson
- Revision 267: published
- Revision 268: published
- Revision 269: published
- Revision 271: published by Joshua Holbrook
- Revision 272: published
- Revision 273: published by Gabriel Farrell
- Revision 275: published
- Revision 277: published by Juri
- Revision 281: published by Kelly Miyashiro
- Revision 282: published by Michael Kessler
- Revision 283: published by Sebastian Tschan
- Revision 284: published by Michael Kessler
- Revision 285: published by Sebastian Tschan
- Revision 286: published by Todd Anglin
- Revision 287: published
- Revision 290: published
- Revision 291: published by Danny
- Revision 292: published by Chris Dickinson
- Revision 295: published by ali: removed cheating benchmarks
- Revision 296: published by Fabiano Nunes
- Revision 297: published
- Revision 298: published
- Revision 299: published
- Revision 300: published by nakamura_to
- Revision 303: published
- Revision 305: published by Attila
- Revision 306: published by nakamura_to
- Revision 308: published by mrchief
- Revision 309: published by Joshua T Kalis
- Revision 311: published by Dony
- Revision 312: published by redsquare
- Revision 314: published by Chris Dickinson
- Revision 315: published
- Revision 316: published by Jens Roland
- Revision 318: published by Jens and last updated
- Revision 319: published by Jens Roland
- Revision 320: published
- Revision 321: published
- Revision 323: published
- Revision 324: published
- Revision 325: published by Jeff Barczewski
- Revision 327: published
- Revision 333: published
- Revision 334: published
- Revision 335: published
- Revision 337: published by Marek
- Revision 338: published by Jakub
- Revision 339: published
- Revision 341: published
- Revision 342: published
- Revision 343: published by Keets
- Revision 344: published
- Revision 346: published
- Revision 348: published
- Revision 349: published
- Revision 350: published
- Revision 352: published by Grant Husbands
- Revision 353: published by [Now produces DOM nodes]
- Revision 354: published by [Added Twitter's Hogan]
- Revision 356: published by Ryan Funduk
- Revision 357: published by [Restored benchmarks that work]
- Revision 359: published by [Defeat jQuery cache]
- Revision 361: published
- Revision 363: published
- Revision 364: published by [Restored working benchmarks - please stop breaking things]
- Revision 365: published by Jarno Keskikangas
- Revision 366: published by Jarno Keskikangas
- Revision 369: published by Ryan Funduk
- Revision 370: published by RubaXa
- Revision 373: published
- Revision 374: published
- Revision 375: published by Vadim M. Baryshev
- Revision 377: published
- Revision 379: published
- Revision 380: published by Matt Robenolt and last updated
- Revision 381: published by hite
- Revision 382: published
- Revision 383: published
- Revision 384: published
- Revision 385: published
- Revision 386: published
- Revision 387: published by Juve
- Revision 388: published by Ronald Holshausen
- Revision 389: published by Brandon Satrom
- Revision 390: published by Brad Dunbar
- Revision 391: published
- Revision 392: published by Brad Dunbar
- Revision 393: published
- Revision 394: published by leodagdag
- Revision 395: published
- Revision 400: published by [jsRender won through incorrect output - removed]
- Revision 401: published by [jQuery was caching - now defeated]
- Revision 402: published
- Revision 404: published
- Revision 405: published by [Please stop restoring broken benchmarks]
- Revision 406: published
- Revision 407: published
- Revision 408: published
- Revision 409: published
- Revision 410: published
- Revision 411: published by [added JsRender, non-optimized API, correct output]
- Revision 412: published
- Revision 413: published
- Revision 414: published
- Revision 415: published
- Revision 416: published
- Revision 417: published
- Revision 418: published by Sergey Kononenko
- Revision 419: published
- Revision 420: published by Vincent Mac
- Revision 421: published
- Revision 422: published
- Revision 423: published
- Revision 425: published
- Revision 427: published by [Restored benchmarks that actually run]
- Revision 428: published
- Revision 429: published
- Revision 430: published
- Revision 431: published by Marcus Greenwood
- Revision 432: published
- Revision 433: published
- Revision 437: published
- Revision 438: published by work
- Revision 439: published by work2
- Revision 440: published by work3
- Revision 441: published by Saabi
- Revision 442: published by TJ
- Revision 443: published by Saabi
- Revision 444: published by TJ
- Revision 445: published by Saabimeister
- Revision 447: published by RC
- Revision 449: published by Saabimeister
- Revision 452: published
- Revision 453: published by Andrey
- Revision 456: published by [Corrected async dust.js]
- Revision 457: published by yui sub
- Revision 458: published
- Revision 460: published by Jarno Keskikangas
- Revision 461: published
- Revision 462: published by Mikko Ohtamaa
- Revision 463: published by stepanj
- Revision 466: published
- Revision 467: published
- Revision 468: published
- Revision 469: published
- Revision 470: published
- Revision 471: published
- Revision 473: published
- Revision 474: published by asyraf
- Revision 475: published
- Revision 478: published by Jeremy Ashkenas
- Revision 479: published and last updated
- Revision 480: published
- Revision 481: published by Fernando Cardoso
- Revision 482: published
- Revision 483: published
- Revision 485: published by Nir
- Revision 486: published
- Revision 488: published by Charlie Stigler
- Revision 489: published by stepanj
- Revision 490: published
- Revision 491: published
- Revision 492: published
- Revision 493: published by tom
- Revision 494: published
- Revision 495: published by stepanj
- Revision 497: published
- Revision 498: published by Charlie Stigler
- Revision 499: published
- Revision 501: published by [Restored last working version]
- Revision 503: published by [It's best if the tests actually run]
- Revision 507: published by [Dust output was incorrect]
- Revision 508: published
- Revision 509: published by Todd
- Revision 510: published
- Revision 511: published
- Revision 512: published by RC
- Revision 513: published
- Revision 515: published by Diego Vilar
- Revision 516: published by glek
- Revision 517: published by kusakyky
- Revision 518: published
- Revision 519: published
- Revision 520: published
- Revision 521: published
- Revision 522: published
- Revision 523: published by imbolc
- Revision 524: published
- Revision 526: published
- Revision 527: published
- Revision 528: published by odbol and last updated
- Revision 529: published by stepanj
- Revision 531: published by Michael Kessler
- Revision 532: published by Jerome
- Revision 534: published by Joel "Rudenoise" Hughes
- Revision 535: published by Victor
- Revision 537: published by Vadim Baryshev
- Revision 539: published by Vadim Baryshev
- Revision 541: published by Thox
- Revision 543: published by Joaquin Arellano
- Revision 544: published by Joaquin Arellano
- Revision 545: published by [Removed tests that did not produce correct output - benchmark still unrealistic]
- Revision 546: published by Joaquin Arellano
- Revision 547: published
- Revision 548: published
- Revision 549: published
- Revision 550: published by Andrey
- Revision 553: published by printercu
- Revision 554: published
- Revision 555: published by Updated Kendo to latest
- Revision 560: published by Paul Engel
- Revision 561: published
- Revision 562: published
- Revision 564: published by Trevor Norris and last updated
- Revision 565: published
- Revision 566: published
- Revision 568: published by Indamix
- Revision 569: published by Indamix
- Revision 570: published by Anton
- Revision 571: published
- Revision 572: published
- Revision 573: published
- Revision 574: published by Alexey Chirkov
- Revision 575: published by Alexey Chirkov
- Revision 576: published
- Revision 577: published by Alexey Chirkov
- Revision 578: published
- Revision 579: published
- Revision 581: published by desire
- Revision 582: published
- Revision 583: published by Nate Cavanaugh
- Revision 584: published by Nate Cavanaugh
- Revision 585: published by Nicolas Joyard
- Revision 586: published by koala
- Revision 587: published
- Revision 588: published by koala
- Revision 591: published
- Revision 592: published by huang47
- Revision 597: published by Adam
- Revision 598: published
- Revision 600: published by Tingan Ho
- Revision 601: published
- Revision 602: published
- Revision 603: published by tenbits
- Revision 604: published by tenbits
- Revision 605: published
- Revision 606: published
- Revision 607: published by Vadim Baryshev
- Revision 609: published
- Revision 615: published
- Revision 616: published
- Revision 617: published
- Revision 618: published
- Revision 619: published
- Revision 620: published
- Revision 621: published
- Revision 622: published
- Revision 623: published
- Revision 624: published
- Revision 625: published
- Revision 626: published by Qichao Yang
- Revision 628: published by Jason Miller
- Revision 635: published
- Revision 636: published
- Revision 638: published
- Revision 639: published by Andras
- Revision 643: published
- Revision 644: published
- Revision 645: published
- Revision 646: published
- Revision 647: published
- Revision 649: published
- Revision 651: published by akamel
- Revision 652: published
- Revision 653: published by rocman
- Revision 654: published by rocman
- Revision 656: published
- Revision 660: published
- Revision 661: published by bear
- Revision 662: published
- Revision 665: published by Warren Benedetto and last updated
- Revision 666: published by Warren Benedetto
- Revision 668: published
- Revision 669: published
- Revision 670: published by tenbits
- Revision 671: published by printercu
- Revision 672: published
- Revision 687: published
- Revision 688: published
- Revision 692: published
- Revision 694: published by Mario
- Revision 695: published
- Revision 697: published
- Revision 698: published
- Revision 699: published
- Revision 700: published by wfreytag
- Revision 701: published by wfreytag
- Revision 703: published
- Revision 704: published
- Revision 705: published by jQuery 2.0 & lodash
- Revision 706: published by Alex Fork
- Revision 707: published by Ferdinand Prantl
- Revision 708: published
- Revision 709: published
- Revision 710: published
- Revision 711: published
- Revision 712: published by Roman
- Revision 713: published by Roman
- Revision 714: published by Roman
- Revision 715: published by Roman
- Revision 716: published by Roman
- Revision 717: published by Roman
- Revision 718: published
- Revision 719: published
- Revision 720: published by Roman
- Revision 721: published by Roman
- Revision 722: published
- Revision 723: published
- Revision 724: published
- Revision 725: published
- Revision 726: published
- Revision 727: published by George Reith
- Revision 728: published by George Reith
- Revision 729: published by Aaron Aichlmayr
0 comments