Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
templte tmpl vs underscore v3
(version: 0)
Comparing performance of:
vanilla + underscore vs tmpl
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.1/underscore-min.js"></script> <script src="https://cdn.jsdelivr.net/npm/blueimp-tmpl@3.19.0/js/tmpl.min.js"></script> <script type="text/template" id="template-underscore"> <% if (obj.name) {%> Hello <%=obj.name%> <% } else { %> Unknown <% } %> </script> <script id="template-tmpl" type="text/x-tmpl"> {% if (name) { %} Hello {%=obj.name%} {% } else { %} Unknown {% } %} </script>
Tests:
vanilla + underscore
if (!window._template) { window._template = _.template(document.getElementById('template-underscore').innerHTML) } window._template({name: 'hello'});
tmpl
tmpl('template-tmpl', {name: 'hello'});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
vanilla + underscore
tmpl
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):
Let's break down the benchmark and its components to understand what's being tested. **Benchmark Overview** The benchmark compares two approaches for rendering templates: Vanilla JavaScript with Underscore.js library (v3) and Blueimp Template engine (tmpl). **Test Cases** There are two individual test cases: 1. **"vanilla + underscore"**: This test case uses Vanilla JavaScript to create a template, and Underscore.js library is used as the templating engine. * The script preparation code includes loading Underscore.js library. * The benchmark definition code creates an instance of the Underscore.js template function using `window._template` (initialized earlier) and passes an object with a `name` property to render the template. 2. **"tmpl"**: This test case uses Blueimp Template engine (tmpl) for rendering templates. * The script preparation code includes loading tmpl library. * The benchmark definition code uses the `tmpl` function from the loaded library, passing a string containing the template content and an object with a `name` property to render the template. **Library Purpose** * **Underscore.js**: A utility library for functional programming in JavaScript. It provides functions for working with arrays, objects, strings, and more. + In this benchmark, Underscore.js is used as a templating engine to render templates using its `template` function. * **Blueimp Template Engine (tmpl)**: A lightweight template engine that allows you to separate presentation logic from application logic. **Special JavaScript Features/Syntax** There's no specific special JavaScript feature or syntax being tested in this benchmark. However, it's worth noting that the use of ES2015 features like `const`, `let`, and template literals (`<%= %>`) is implied, as they are present in the code snippets. **Pros and Cons of Each Approach** * **Vanilla JavaScript with Underscore.js library (v3)** + Pros: - Highly customizable and flexible - Can be easily extended or replaced with other libraries + Cons: - May have a steeper learning curve due to the need to understand template logic and Underscore.js functions * **Blueimp Template Engine (tmpl)** + Pros: - Lightweight and easy to use, especially for simple templates - Fast rendering performance + Cons: - Limited customization options compared to vanilla JavaScript with Underscore.js library **Alternatives** Other template engines or approaches that could be used instead of Blueimp Template Engine (tmpl) include: * Handlebars.js * Mustache.js * Pug.js * Jinja2 * EJS These alternatives might offer different trade-offs in terms of performance, customization options, and complexity. Keep in mind that this benchmark is focused on comparing two specific approaches rather than evaluating the overall suitability of template engines for a particular use case.
Related benchmarks:
Find: Native vs Underscore vs Lodash
Get html, innerHTML vs $.html--
templte tmpl vs underscore
templte tmpl vs underscore v2
Comments
Confirm delete:
Do you really want to delete benchmark?