Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're using a template engine to render UI on the client side, it's helpful to have a rough idea of the relative performance:

http://jsperf.com/dom-vs-innerhtml-based-templating/45

Here's a screenshot of the results: http://cl.ly/42CP

It can make a difference, because UI-rendering can often be the performance bottleneck in a JS web app ... especially in older browsers like Internet Explorer.

Although, perhaps it isn't a problem at all -- looking at the source, it doesn't appear as though Jade supports IE:

https://github.com/visionmedia/jade/blob/master/lib/jade.js#...



I added a test[1] for Handlebars.js, which is identical to mustache, but pre-compiled. It comes in 2nd in my tests. [2]

[1]: http://jsperf.com/dom-vs-innerhtml-based-templating/47 [2]: http://cl.ly/3002090Y093I383N013r


Hm, what about https://github.com/jquery/jquery-tmpl, jquerys official templating plugin?

I use this one with a js-app in conjunction with knockout.js and a few others.

So performance of this one would be interesting, too.

Btw: The actual benchmark is really compelling.


JSPerf.com is like a wiki -- so by all means, please edit the page and add a "jquery-tmpl" test.


Yes, i know. I'am just very tired. But anyway, i've added it now.

http://jsperf.com/dom-vs-innerhtml-based-templating/46

It performs really poor..


Oh my goodness -- that's really fascinating. I had no idea that the new jQuery-tmpl templates were that egregiously slow. (Nearly 100x slower, for those who don't want to run the tests.) Thanks for adding 'em to the list.


No problem after all. :) It's really horrible. But it's not that bad for me. knockout.js does a good job with partial rendering via databinding (ie. only rerender what really changed or is added).

Also it's just beta 1, lets see what happens next.

But adding Eco Template as engine for knockout.js would be a great idea, i think...


jquery-tmpl is "Resig Micro-Templates" in his screenshot.

Should be plenty fast enough for all but the most demanding use-cases.


I also got errors with Jade and Eco on Opera 10. The whole page fails with Opera 11, too: http://cl.ly/3s2a0i3V1s422b2Z1Z3C




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: