#Question about rendering dynamic components & multiple small JS files

11 messages · Page 1 of 1 (latest)

quick robin
#

So I am planning to create a website solution with NestJS based on a CMS.

The CMS will provide the page structure and nestjs will combine the components/blocks, to create the page.

The components (HTML) files, will be in a separate NPM package, so I can have a "theme" functionality and easily change a website theme by just installing another NPM package.

But I have a problem.

Some components will have accompanying .js files for different features, for example a Calendar component with its logic in a calendar.js file.

Considering I do not know the page structure at build time, I can not build a bundle with all the .js files

Would it be okay, to have the .js files minified, and concatenated during page render in nestjs? So that I provide only one .js per page request, instead of loading all .js files for each component?

hot harbor
#

@quick robin - Um, I think you might be mixing things up with Nest. Usually with Nest, you’d build the CMS backend, thus having a CMS behind Nest doesn’t really make sense.

quick robin
#

I could probably just use express since maybe nestjs is too much for this, but I like the features provided by nest and since it already forces a specific coding style, it could actually help me structure my project better, than just freely doing something with express

#

and for expanding in future could also be better

hot harbor
#

implement themes for those components, layouts, and handle that on the server side

@quick robin - Not sure what you mean here. You want Nest to be a server-side frontend for a CMS backend? If Directus has an API, why not just create a SPA with SSR for it?

quick robin
# hot harbor > implement themes for those components, layouts, and handle that on the server...

I have right now a SPA with SSR, so far it works as I wish, but now I am looking to create the most lightweight final websites I can, and I planned to use htmx and alpinejs instead of React, and for example htmx expects routes that return html to append into the DOM

After some research I found out that I could do that with NestJS, I am just thinking how I should set everything up compared to my React project

#

So basically, yes, I want Nest to be a server-side frontend for my CMS, I'd like to avoid SPAs for this project

hot harbor
#

so far it works as I wish

Ever heard of never mess with a working system? 😛

But, yeah. Theoretically you could use Nest to serve server rendered pages, but that isn't its strong suit. Building APIs is.

#

Oh, and adding Nest to the mix will be far from "most lightweight final websites I can". Just sayin...

quick robin
# hot harbor > so far it works as I wish Ever heard of never mess with a working system? 😛 ...

Ever heard of never mess with a working system? 😛

It is more like trying a different approach, as a side project

My aim is to have the end result frontend responding fast, and trying to keep the tab RAM usage low, maybe due to my coding style, or maybe due to React, I havent managed to bring the tab RAM under 100mb with the SPA so far

And htmx sounded better from what I've read so far, alpinejs is also light and should help with some ease in creating different components, I just had to find a backend framework that would prepare my HTML