You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Template compilation and interpolation is a resource consuming task.
The algorithms in most template engines (including regular expression matching) runs in synchronous mode and can block the event loop. Blocking the event loops can lead to:
Janky UI in the frontend
Inaccessible server on the backend
Use worker threads if you know that your templates are going to be large or contain too many paths.
Parsing the template can be particularly resource consuming (even for a light library like Micromustache). There are multiple options available to put a limit on how the template is parsed.
Multi-level processing
This one is very important because one of the main use cases (and its original reason for existence) for MicroMustache is internationalization and it's common for i18n templates to require multi-level interpolation. Demo a real use case with the i18n.js example.
Performance
Use paths like a.b.c instead of a['b']['c'] because it is much faster to parse.
If it is possible compile the template once and reuse the results.
The text was updated successfully, but these errors were encountered:
Tips and tricks
To put in the wiki or in the code
Security
Template compilation and interpolation is a resource consuming task.
The algorithms in most template engines (including regular expression matching) runs in synchronous mode and can block the event loop. Blocking the event loops can lead to:
Use worker threads if you know that your templates are going to be large or contain too many paths.
Parsing the template can be particularly resource consuming (even for a light library like Micromustache). There are multiple options available to put a limit on how the template is parsed.
Multi-level processing
This one is very important because one of the main use cases (and its original reason for existence) for MicroMustache is internationalization and it's common for i18n templates to require multi-level interpolation. Demo a real use case with the i18n.js example.
Performance
Use paths like
a.b.c
instead ofa['b']['c']
because it is much faster to parse.If it is possible compile the template once and reuse the results.
The text was updated successfully, but these errors were encountered: