6

with is so bad that it is forbidden in ES5 strict mode.

Function constructor is very slow.

Yet, John Resig's micro templating is advertised as light, uses both mentioned bad features of Javascript. (same with another light templating - underscore's, which is a fork of it)

Now a question: How seriously should i be concerned about performance impact of using those template engines ?

Should i sacrifice their flexibility and simplicity for speed gains that other engines (like Mustache, or XTemplates) might provide ?

Community
  • 1
  • 1
c69
  • 19,951
  • 7
  • 52
  • 82
  • 2
    Are you building a Facebook-sized operation? Or a small website that no one will use? 'impact' is relative. – Marc B Mar 20 '12 at 15:58
  • well, Facebook's JS is not _that_ huge, complex or particularly fast. My concerns are directed for HTML apps on embedded devices. (So they are supposed to run for very long time (few hours without page reload), compared with facebook's 5 minutes / 10 transitions) and also they must render without *any* noticeable delays... – c69 Mar 20 '12 at 16:06
  • Are you going to run it on coffepots with 1 MHz CPU or wrap every span in a template? Otherwise it is hardly so important. A function call costs far below 1ms. – kirilloid Mar 20 '12 at 16:25
  • 1
    John Resig doesn’t query the DOM, he just glances at it and gets all the elements he was expecting. Clearly it works differently for the rest of us. http://benalman.com/news/2009/12/john-resig-javascripts-chuck-norris/ – Matt Gibson Mar 20 '12 at 16:44
  • How about if you make a slow/test, just create a template, run it like 10000 times, take the time, repeat with whatever other template engine you know and thats it. The code is extremelly simple, https://gist.github.com/topliceanu/1537847 it must be fast. – useless May 29 '13 at 14:13

0 Answers0