Don't compile all partials at once#69
Don't compile all partials at once#69nwhittaker wants to merge 3 commits intoHenrikJoreteg:masterfrom nwhittaker:master
Conversation
Derive and pass Mustache only the partials that are needed for the given template compilation. Otherwise the first template compilation is slammed with having Mustache compile /every/ template -- which can have a significant performance impact in older browsers.
|
Seems like running everything through a regex ahead of time would have other performance implications. Do you have any tests to show this is, in fact faster/better? |
|
Good point. I'll do some further benchmarking to see if it'd be better do the regex at a template's compile time. FWIW, in IE7, the change did decrease the time taken to compile the first template from ~30s to ~5s. |
|
I added a few jsperf tests for this issue. According to the results, it seems like the best course of action would be to keep the RegEx but move it to inside the render closure. If you agree, I can open a new pull request.
|
|
Sorry this has been sitting too long, I'm not actively using this project and have been having trouble keeping up with maintenance, would be happy to add you if you're interested: #81 |
Compile only the partials that a given template needs. For an app with a lot of complicated templates, this can improve performance -- especially for older JavaScript engines.