handlebars-lang / handlebars-lang/handlebars.js

New benchmark blog post

Open
#2,085 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
18.7k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

@jaylinski

Well, I'm not sure what happened here... 😀
The expected / advertised performance gain between Mustache and Handlebars... I was unable to (re)produce it...

I have made two benchmarks:
- minimal : 3 variables, 2 line template --> Mustache was faster in all scenarios (66%)
- maximal : 21 variables, 33 line template --> Handlebars was faster in all scenarios (6% for precompiled, 0.7% without precompilation)

Image

This is the code:
https://github.com/itenium-be/TemplatingEngineBenchmarks

The code for maximal-precompiled:

```ts
import * as b from 'benny';
import Handlebars from 'handlebars';
import './maximal-precompiled-hbs.js';
import Mustache from 'mustache';
import { data, mustacheTemplate } from './maximal.js';

export default function suite() {
return b.suite(
'Template Engine Benchmark: Maximal precompiled',

b.add('Handlebars', () => {
Handlebars.templates['maximal-precompiled'](data);
}),

b.add('Mustache', () => {
Mustache.render(mustacheTemplate, data);
}),

b.cycle(),
b.complete(),

b.save({ file: 'maximal-precompiled', version: '1.0.0' }),
b.save({ file: 'maximal-precompiled', format: 'chart.html' }),
);
}

export const data = {
clientName: "Alice Corp",
consultantName: "John Doe",
projectName: "NextGen App",
projectMonth: "June 2025",
billingPeriodStart: "2025-06-01",
billingPeriodEnd: "2025-06-30",
invoiceNumber: "INV-2025-0625",
orderNumber: "PO-123456",
days: [
{ date: "2025-06-03", hours: 8, activity: "Feature implementation" },
{ date: "2025-06-04", hours: 6, activity: "Bug fixing" },
],
totalHours: 14,
hourlyRate: 85,
subtotal: 1190,
discount: true,
discountAmount: 190,
discountDescription: "Loyalty discount",
totalExclVat: 1000,
vatRate: 21,
vatAmount: 210,
totalInclVat: 1210,
notes: "Approved by client via email.",
companyName: "Itenium Consulting"
};

export const mustacheTemplate = `
Hello {{clientName}},

Please find below the summary for project **{{projectName}}** for the month of {{projectMonth}}.

Consultant: {{consultantName}}
Billing Period: {{billingPeriodStart}} - {{billingPeriodEnd}}
Invoice Number: {{invoiceNumber}}
{{#orderNumber}}Order Number: {{orderNumber}}{{/orderNumber}}

{{#days}}
- {{date}}: {{hours}}h - {{activity}}
{{/days}}

Total hours: {{totalHours}}
Hourly Rate: €{{hourlyRate}}
Subtotal: €{{subtotal}}

{{#discount}}
Discount: -€{{discountAmount}} ({{discountDescription}})
{{/discount}}

Total (excl. VAT): €{{totalExclVat}}
VAT ({{vatRate}}%): €{{vatAmount}}
**Grand Total: €{{totalInclVat}}**

{{#notes}}
Note: {{notes}}
{{/notes}}

The signed timesheet is attached to this message.

Kind regards,
The {{companyName}} team
`;
```

Am I doing something wrong? 😀

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked TemplatingEngineBenchmarks repository and running the minimal and maximal suites shown in the issue, including the precompiled case. Compare the reported Mustache and Handlebars results and determine whether the benchmark setup explains the discrepancy; the issue provides no implementation target or completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, javascript, typescript
Domain
performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.