r/Backend • u/wasitshafi • 17h ago
Template engine EJS vs Eta for a new Node.js project with SSR(don't want to use NextJS), which to choose?
Hi,
I am about to start a new project with SSR (Node.js); previously, I have used ejs/handlebars. Currently, I am not very familiar much eta.
eta claims to be faster than ejs, anyone worked with both?
Highly appreciate your suggestions/comments.
ejs: https://www.npmjs.com/package/ejs
eta: https://www.npmjs.com/package/eta
Thanks
1
Upvotes



1
u/jakubiszon 6h ago edited 4h ago
I would question why would you choose either of them. I don't really know eta but from the first look - seems very similar to ejs. The approach ejs uses is very powerful - you can embed any code into the template. This ability is also a curse.
A key question is - who would prepare the templates? If at any point users were allowed to prepare a template - you should use something much more restrictive than ejs. The users will shot themselves in the foot and not because of bad will. They can write a simple loop - everyone can do that - but they will initialize the counter with a function call returning NaN and your backend will loop forever. I have seen this in production btw :D
edit: the exit condition needs to check for inequality tho
NaN < something.lengthwill returnfalsebutNaN != something.lengthwill always returntrue.2
u/Beagles_Are_God 16h ago
Hey, tbh i have no idea about it but you may want to check it.
If you are using Hono for your backend check HonoX, it’s kinda like NextJS BUT your server is HONO and without a lot of the NextJS overhead
1
u/ndaidong 4h ago
I recommend using VentoJS. It has simple syntax and makes it easy to write loops and logic. I've used it since its creator first released it and have never looked for another template engine. Before that, I’d used several different template engines: EJS → Handlebars → Pug → Nunjucks. VentoJS combines the strengths of all of them and adds some valuable improvements, while remaining lightweight and fast.