micromustache
micromustache copied to clipboard
Support async compile and rendering to avoid event loop for large & complex templates
The synchronous render() method can occupy the event loop if the input is huge. We can't do much about it without adding lots of complexity or relying on Workers.
We could add a renderAsync() function that does the rendering work in chunks.
Also have a look at tokenization because that can block the event loop too.
This could be achieved by passing an identity function (x => x) to the renderFnAsync() but with the current setup the code wouldn't look super intuitive. It would be better to add a option for a function that allows processing varNames and turning them into something that render*() would use in its interpolation algorithm.