Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
EJS vs doT
(version: 11)
EJS latest (dev) vs doT latest (dev)
Comparing performance of:
EJS vs doT
Created:
8 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script> var exports = {}; var require = function(){ return { escapeRegExpChars: function (string) { return string ? String(string).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') : ''; } }; }; </script> <script src="https://rawgit.com/olado/doT/master/doT.js"></script> <script src="https://rawgit.com/mde/ejs/master/lib/ejs.js"></script> <script> require = undefined </script> <div id="insertionPoint"></div>
Script Preparation code:
var sharedVariables = { header: "Header", header2: "Header2", header3: "Header3", header4: "Header4", header5: "Header5", header6: "Header6", list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] }; var dotT = doT.template("<div><h1 class='header'>{{= it.header }}</h1><h2 class='header2'>{{= it.header2 }}</h2><h3 class='header3'>{{= it.header3 }}</h3><h4 class='header4'>{{= it.header4 }}</h4><h5 class='header5'>{{= it.header5 }}</h5><h6 class='header6'>{{= it.header6 }}</h6><ul class='list'>{{ for (var i = 0, l = it.list.length; i < l; i++) { }}<li class='item'>{{= it.list[i] }}</li>{{ } }}</ul></div>"); var ejsT = ejs.compile("<div><h1 class='header'><%- header %></h1><h2 class='header2'><%- header2 %></h2><h3 class='header3'><%- header3 %></h3><h4 class='header4'><%- header4 %></h4><h5 class='header5'><%- header5 %></h5><h6 class='header6'><%- header6 %></h6><ul class='list'><% for (var i = 0, l = list.length; i < l; i++) { %><li class='item'><%- list[i] %></li><% } %></ul></div>"); var ip = document.getElementById('insertionPoint');
Tests:
EJS
ip.innerHTML = ejsT(sharedVariables);
doT
ip.innerHTML = dotT(sharedVariables);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
EJS
doT
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 explain the benchmark in detail. **Benchmark Purpose** The benchmark measures the performance difference between two templating engines, EJS (Embedded JavaScript) and doT (a lightweight JavaScript template engine), when rendering HTML templates with shared variables. **Options Compared** Two options are compared: 1. **EJS**: Embedded JavaScript templating engine. 2. **doT**: A lightweight JavaScript template engine. **Pros and Cons of Each Approach** **EJS:** Pros: * Easier to use, especially for developers familiar with Node.js and Express.js. * Supports more advanced features like conditionals, loops, and functions. * Has a larger community and more resources available. Cons: * Slower performance compared to doT due to the overhead of executing JavaScript code within the template. * Requires more memory to store the compiled templates. **doT:** Pros: * Faster performance since it only renders static HTML templates without executing JavaScript code. * Smaller footprint, requiring less memory to store the compiled templates. * Easier to optimize for specific use cases. Cons: * Less intuitive and harder to learn for developers unfamiliar with template engines. * Fewer advanced features compared to EJS. **Library and Syntax** Both options use a similar syntax for templating. The main difference lies in how the templates are rendered: * **EJS**: Uses the `<%- %>` syntax for escaping and interpolation, where `<% %>` is used for executing JavaScript code. * **doT**: Uses the `{{= }}` syntax for escaping and interpolation. **Special JS Features** No special JS features or syntaxes are mentioned in this benchmark. **Alternative Templating Engines** Other popular templating engines that might be alternatives to EJS and doT include: 1. Handlebars: A widely-used, fast, and feature-rich template engine. 2. Mustache: A lightweight, easy-to-use template engine with a simple syntax. 3. Pug (formerly Jade): A fast, modular, and feature-rich template engine with a focus on performance. **Benchmark Preparation Code** The preparation code consists of: 1. Shared variables defined as an object (`sharedVariables`). 2. doT template compiled using `doT.template()`. 3. EJS template compiled using `ejs.compile()`. **Individual Test Cases** Each test case is a separate benchmark that renders the same template with shared variables, but uses either EJS or doT to do so. I hope this explanation helps software engineers understand the benchmark and its design!
Related benchmarks:
lodash merge vs object.assign vs lodash assign
lodash.merge vs object.assign vs spread
Comparing different object merge methods
Object.values vs _.values
lodash merge vs object.assign vs spread for 3 objects
Comments
Confirm delete:
Do you really want to delete benchmark?