Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Render Test: Handlebars vs Hogan vs Mustache
(version: 0)
Comparing performance of:
Handlebars vs Hogan vs Mustache
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.min.js" integrity="sha512-RNLkV3d+aLtfcpEyFG8jRbnWHxUqVZozacROI4J2F1sTaDqo1dPQYs01OMi1t1w9Y2FdbSCDSQ2ZVdAC8bzgAg==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/4.0.1/mustache.min.js" integrity="sha512-6AXIWogbKpsHvoZJrJtHpIYES4wP8czSj0zk7ZfwOYS8GWYFNSykwdfapt7yQc4ikZytemBu+QyVObzBHJMwYg==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/hogan.js/3.0.2/hogan.min.js" integrity="sha512-F6j8lc1UBrmZHqUGreg4gNVVMCehTbf/LU0s/nnsQJYVeFSdpci+fcL48gsTd1Fbf08sD/kL+is2QiEssvJ70g==" crossorigin="anonymous"></script>
Script Preparation code:
var template = "<strong>This is a slightly more complicated {{thing}}.</strong>.\n{{! Just ignore this business. }}\nCheck this out:\n{{#hasThings}}\n<ul>\n{{#things}}\n<li class={{className}}>{{word}}</li>\n{{/things}}</ul>.\n{{/hasThings}}\n{{^hasThings}}\n\n<small>Nothing to check out...</small>\n{{/hasThings}}"; var data = { thing: 'thing', hasThings: true, things: [ { className: 'class1', word: 'word1' }, { className: 'class2', word: 'word2' }, { className: 'class3', word: 'word3' }, ] }; var handlebarsRenderer = Handlebars.compile(template); var hoganRenderer = Hogan.compile(template); Mustache.parse(template);
Tests:
Handlebars
handlebarsRenderer(data)
Hogan
hoganRenderer.render(data)
Mustache
Mustache.render(template, data)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Handlebars
Hogan
Mustache
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and explain what's being tested, compared options, pros and cons of each approach, library usage, special JS features or syntax, and alternatives. **What is being tested?** The benchmark measures the rendering performance of three templating engines: Handlebars, Hogan, and Mustache. The test creates a complex template with nested loops, conditionals, and variables, and then passes sample data to each engine to render the template. **Options compared:** 1. **Handlebars**: Uses the Handlebars.js library to compile and render the template. 2. **Hogan**: Uses the Hogan.js library to compile and render the template. 3. **Mustache**: Uses the Mustache.js library to parse and render the template. **Pros and cons of each approach:** 1. **Handlebars**: * Pros: Well-established library with a large community, fast rendering performance, and easy-to-use API. * Cons: Can be less flexible than Hogan or Mustache due to its more rigid syntax. 2. **Hogan**: * Pros: Faster rendering performance compared to Handlebars, more flexible syntax, and supports both imperative and declarative templating. * Cons: Smaller community compared to Handlebars, and some users may find the syntax less intuitive. 3. **Mustache**: * Pros: Simple and lightweight library, fast rendering performance, and easy-to-use API. * Cons: Less flexible than Hogan or Handlebars due to its simpler syntax. **Library usage:** 1. **Handlebars**: Used for template compilation and rendering. 2. **Hogan**: Used for template compilation and rendering. 3. **Mustache**: Used for template parsing and rendering. **Special JS features or syntax:** 1. **Handlebars**: Uses the `{{}}` syntax for variables and expressions, as well as `{#}` and `{^}` for loops and conditionals. 2. **Hogan**: Supports both imperative (`hogan.compile()`) and declarative (`hogan.render()`) templating approaches. 3. **Mustache**: Uses the `{{}}` syntax for variables and expressions, as well as `{#}` for loops. **Alternatives:** 1. **Pug**: A templating engine that uses a more concise syntax and is known for its performance. 2. **EJS (Embedded JavaScript)**: A templating engine that allows developers to embed JavaScript code directly into templates. 3. **Liquid**: A templating engine used in Ruby on Rails, which provides a flexible and customizable syntax. In summary, the benchmark tests the rendering performance of three popular templating engines, Handlebars, Hogan, and Mustache, with a focus on their syntax, rendering speed, and flexibility. The results can help developers choose the best template engine for their specific use case.
Related benchmarks:
mustache rendering performance-fix
Handlebars vs Hogan vs Mustache rendering
mustache vs handlebars rendering performance
Handlebars vs Hogan vs Mustache (Updated versions2)
Comments
Confirm delete:
Do you really want to delete benchmark?