How to bundle dinamically generated webpages?

Hi there.
I’ve recently learned that you can use webpack to bundle your static webpage. The bundling of .js files saves time by reducing the quantity of http connections and so on.
The thing is that i have a node js app that serves dynamically generated webpages. Depending on the user input, the app delivers a web page that uses different .js files.
My concern is that sometimes that dynamically generated web page uses many different .js files that represent many http connections and i 'd rather have the user connect once and download a bundled .js file that contains all the .js files needed for that dynamically generated page.

How do i do that? Can i use webpack to bundle/minify all the content that my dynamically generated page will need? Should i do that bundling at the moment of routing the request? I’m kinda confused.

Thank you for clarifying.


I’m no expert here but no one has piped in…

Yes, you can bundle your files with something like webpack. It’s a little complicated to setup but can do magical things. One of the things it can do is bundle. It can also minify and uglify and treeshake and all sorts of cool things.

So yeah, in the simplest form, it will reduce your site down to a few html, css, and js files that are minimized as much as possible. I don’t know but there my also be provisions for breaking those apart a bit for different sections of the app so it doesn’t get too big and cause a slow load, but there are other ways to deal with that too.

So, why not do some webpack tutorials. It would look really good on a resume - I see that on job listings sometimes. Webpack is something that a lot of us use but never really take the time to master. You could be that guy.

Again, I’m no expert on this, but that is my $.02.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.