Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Handlebars vs Hogan vs Mustache (Updated versions2)
(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.8/handlebars.min.js" integrity="sha512-E1dSFxg+wsfJ4HKjutk/WaCzK7S2wv1POn1RRPGh8ZK+ag9l244Vqxji3r6wgz9YBf6+vhQEYJZpSjqWFPg9gg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/4.1.0/mustache.min.js" integrity="sha512-HYiNpwSxYuji84SQbCU5m9kHEsRqwWypXgJMBtbRSumlx1iBB6QaxgEBZHSHEGM+fKyCX/3Kb5V5jeVXm0OglQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/hogan.js/3.0.2/hogan.min.js"></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 handlebarsRenderer = Handlebars.compile(template); var hoganRenderer = Hogan.compile(template); var mustacheRender = Mustache.parse(template);
Tests:
Handlebars
Handlebars.compile(template)
Hogan
Hogan.compile(template)
Mustache
Mustache.parse(template)
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:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0
Browser/OS:
Chrome 122 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Handlebars
4255324.0 Ops/sec
Hogan
1194848.6 Ops/sec
Mustache
1197930.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of Handlebars, Hogan, and Mustache microbenchmarks. **Benchmark Overview** The provided benchmark compares the performance of three templating engines: Handlebars, Hogan, and Mustache. The goal is to determine which engine renders templates faster. **Templating Engines** 1. **Handlebars**: A popular JavaScript templating engine developed by Chris Ebersole. It's widely used in the industry for its flexibility, scalability, and extensive ecosystem. 2. **Hogan**: A lightweight, embeddable templating engine created by Adam Freid. It's designed to be fast and easy to use, making it a great choice for web applications that require rapid template rendering. 3. **Mustache**: Another popular JavaScript templating engine developed by Jeff Effman. Mustache is known for its simplicity, readability, and ease of use. **Options Compared** The benchmark compares the performance of each templating engine on the same input template: * Handlebars.compile(template) * Hogan.compile(template) * Mustache.parse(template) These options differ in how they parse and compile the template: * **Handlebars**: Compiles the entire template into an abstract syntax tree (AST) before rendering. * **Hogan**: Parses the template and compiles it to a lightweight, bytecode format using a custom parser. * **Mustache**: Parses the template using a recursive descent parser and then executes the resulting AST. **Pros and Cons of Each Approach** 1. **Handlebars**: Pros: * Robust feature set * Large community support * Easy to extend with plugins Cons: * Can be slower due to full compilation * More memory-intensive 2. **Hogan**: Pros: * Extremely lightweight (only 6KB gzipped) * Fast rendering performance * Easy to use and embed Cons: * Limited feature set compared to Handlebars * Smaller community support 3. **Mustache**: Pros: * Simple, easy-to-read syntax * Fast rendering performance * Lightweight (only 11KB gzipped) Cons: * Smaller community support compared to Handlebars * Limited feature set **Other Considerations** When choosing a templating engine, consider the trade-offs between performance, flexibility, and ease of use. If you need a robust feature set and are willing to sacrifice some performance, Handlebars might be the best choice. For fast, lightweight rendering, Hogan or Mustache could be a better fit. **Library Usage** The benchmark uses the following libraries: * **Handlebars**: Version 4.7.8 * **Hogan**: Version 3.0.2 * **Mustache**: Version 4.1.0 These libraries are widely used and maintained, ensuring that the benchmark results are relevant to real-world use cases. **Special JS Features or Syntax** The benchmark does not specifically target any special JavaScript features or syntax. However, it's worth noting that Handlebars and Mustache support more advanced features like conditionals, loops, and functions, which can impact rendering performance. In conclusion, the Handlebars vs Hogan vs Mustache benchmark provides a useful comparison of three popular templating engines. By understanding the pros and cons of each approach, developers can make informed decisions about which engine to use for their specific needs.
Related benchmarks:
mustache rendering performance-fix
Handlebars vs Hogan vs Mustache
Handlebars vs Hogan vs Mustache rendering
Hogan vs Mustache vs HB
Comments
Confirm delete:
Do you really want to delete benchmark?