https://github.com/stopsopa/template-engines-benchmark
https://github.com/stopsopa/template-engines-benchmark
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stopsopa/template-engines-benchmark
- Owner: stopsopa
- Created: 2026-04-06T21:38:06.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-06T23:13:34.000Z (3 months ago)
- Last Synced: 2026-04-06T23:24:59.105Z (3 months ago)
- Language: TypeScript
- Size: 54.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Template Engines Benchmark
A performance-oriented experiment focused on benchmarking various JavaScript template engines and documenting critical findings. This repository aims to identify the fastest and simplest solutions, with a deep dive into optimization techniques like the Lodash `variable` option.
## 🚀 Key Findings
It turns out that **Lodash can be the fastest engine here**, which is pretty surprising.
The secret is the `variable` option. Normally, Lodash is slow because it uses an old `with` block. By turning on `variable`, you skip that and get a **3.5x speed boost**, putting Lodash at the top of the list.
```javascript
// Slow: uses 'with' (not recommended)
_.template("our template");
// Fast: 3.5x performance gain
_.template("our template", { variable: "data" });
```
Inconvenient aspect of that is that we have to always use :
```js
<%= data.name %>
// instead of:
<%= name %>
// which forces us to do:
const tmp = _.template('Hello <%= data.name %>', { variable: 'data' });
const html = tmp({ name: 'John' });
// instead of:
const tmp = _.template('Hello <%= name %>'); // <- shorter
const html = tmp({ name: 'John' });
```
Recomendation would be to define single letter variable:
```js
const tmp = _.template("Hello <%= d.name %>", { variable: "d" });
const html = tmp({ name: "John" });
```
.. that should make it more reasonable/convenient to use.
## 📊 Details & results
- 📝 **[benchmark/summary.log](benchmark/summary.log)**: The latest raw results from our automated benchmark runs.
- 📖 **[benchmark/README.md](benchmark/README.md)**: Detailed analysis and conclusions regarding the results.
- ⚙️ **Manual Workflow**: This benchmark can be triggered manually via GitHub Actions to verify performance across different environments.