If you’re in a hurry, head over to the Github Repo here or glance through the documentation at https://squirrelly.js.org. Or, check out performance comparisons here. [Hint: Squirrelly is fastest]
A while ago, I started searching for the perfect JavaScript template engine. It had to be simple, performant, flexible, and lightweight. The problem was, none of the template engines out there really seemed to fit the bill.
One of the main issues was the tradeoff between size and power — most of the popular and flexible template engines add a lot of overhead. According to Bundlephobia, here are the bundle costs (gzipped and minified) of some notable template engines.
In contrast, some of the more lightweight templating engines — like doT or Mustache — lack features like precompilation, helpers, filters, custom delimeters, or running native code.
Squirrelly weighs only 2.6KB, but it’s still incredibly flexible and performant — in fact, in a benchmark developed by MarkoJS, Squirrelly outperforms the other template engines in terms of speed almost every time!
What makes Squirrelly so fast
Features:
{{#else}}
)Comments
{{!--This is a comment--}}
References
{{title}}
Filters
{{title|filter}}
Helpers (like functions, but in the template)
{{helpername(parameters)}}
Some content
{{#helperblock}}
Other content
{{/helpername}}
Conditionals (a kind of helper)
{{if(options.value==="hello")}}Hi!{{#else}}How are you?{{/if}}
Partials
{{include(mypartial)/}}
Performance benchmarks are here, run using tests from MarkoJS: https://github.com/nebrelbug/squirrelly-benchmarks. Squirrelly is almost always fastest, and usually has one of the smallest compiled sizes too.
Read the documentation at squirrelly.js.org for more info. If you liked this post, give it some applause, or star the Github Repo!
Squirrelly could also always use collaborators. Join the team by heading over to the repository and creating an issue or pull request.