question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically Rendering with Node.js Emails is Slow

See original GitHub issue

I want to use Maizzle to dynamically render emails with Node.js. For example to include the username in the content.

Is there a recommended approach to do this? Because my current implementation is very slow:

app.get('*', async (req, res) => {
  const template = await fsPromises.readFile(
    path.join(basePath, 'src/templates', `${req.path}.html`),
  )

  const configPath = path.join(basePath, './config.production')
  const {html} = await Maizzle.render(template.toString(), {
    maizzle: require(configPath),
  })

  res.send(html)
})

…rendering one email on my Kubernetes cluster takes 18 seconds. I guess it’s because TaildwindCSS needs to be compiled every time.

There must be a better way?!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
claudiu-clearpointcommented, Aug 6, 2021

With the Maizzle version 3.6.1, env: ‘production’ and without purge or with but undefined or array and is rendering it in 5 sec which is less than 18sec but is still slow. I also noticed the warnings: warn - You have enabled the JIT engine which is currently in preview. warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.

0reactions
claudiu-clearpointcommented, Aug 6, 2021

without mode jit will be 23 sec. probably the 5 sec is the best performance for the render function but because is too long, the alternative solution of the render function from flolu seems to be the only solution as it will be under 1 sec

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS + Template engine render slower comparing PHP
First of all, Jade is really slow, and may be slowest template engine (and that is not a secret). And the second problem...
Read more >
Render dynamic content in Node.js using templates
In this article, we will see how we can render the front-end using Node.js which is very helpful to display static or dynamic...
Read more >
Demystifying Server Side Rendering: Let's build our own SSR ...
Transmitting a lot of bytes in the form of JS code to your client (who are suffering from a slow connection); You're delaying...
Read more >
Best practices to increase the speed for Next.js apps
Using server-side rendering will help your app reduce the time required ... To use dynamic import, you just need to import the code...
Read more >
What is server-side rendering and how does it improve site ...
This is done by using a backend runtime such as Node.js that can run the JavaScript code to build the UI components. Here's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found