r/learnjavascript • • 9h 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

6 comments sorted by

1

u/misterrpg 8h ago

Have you considered Astro?

2

u/wasitshafi 7h ago

u/misterrpg Yes, Thanks for the suggestion, currently I am looking for pure Node. js-based approaches only

2

u/Discordbothost 9h ago

I'd start with EJS since you already know it. If speed's a concern, render one real page with both engines after warming the template caches. Time the render separately from the DB call so you can see how much switching engines could save.

1

u/Own_Giraffe987 8h ago

Timing the render is a smart move. EJS has great community support too, so debugging's easier.

1

u/UhLittleLessDum 7h ago

Do you need client side components? If not, then just template that s--t.... Use like handlebars or whatever npm pacage implements their logic in Rust if you want to be fast.

1

u/Worldly-Lobster-7728 4h ago

Beyond speed, the biggest practical difference is layouts. EJS doesn't have built-in layouts or blocks, so you usually stitch pages together with header and footer includes. Eta ships layouts and named blocks out of the box, which is handy for page-specific scripts or sidebars.

Switching does take a little getting used to. Eta puts your data on "it" by default instead of bare variables, and unescaped output uses <%~ instead of <%-. If you're using Express with Eta v4, you either render templates manually and send the string, or add a small engine wrapper.