My thought is that I would have to do specific work that I can't imagine Webpack could "guess" would work for me in every circumstance...
My thought is that I would have to do specific work that I can't imagine Webpack could "guess" would work for me in every circumstance...
var myComponent = import('./myComponent')
instead of classic imports import myComponent from './myComponent'
Then Webpack automatically generates separate js files and these files are loaded by the browser only when the dynamic imports are called.Reference: https://webpack.js.org/guides/lazy-loading
If so, what does this improve? Time to first paint? Time to first interaction? Time to DOM ready? I looked at their page, and it doesn't seem to answer questions like this simply. It just says when a user requires the code it loads it.... huh?
How much code are people putting into their apps that this would ever be needed? (serious question)
When I do site analyzing, 99/100 the images/css are the biggest contributors to site size, have JS libraries gone nuts?
To be redundant (for absolute clarity) you know how to use Webpack, you do use it, it offers value to you, but not for building websites? Can I assume it only has value (for you) with building complex webapps? (can I also assume this is for Node.js?)
https://electronjs.org/docs/tutorial/about
This says it's made with Node.js...
> If so, what does this improve? Time to first paint? Time to first interaction? Time to DOM ready?
Could be any or all of those, yes, depending on architecture. Webpack bundles CSS, images, etc into combined JS files ("chunks"), tries to get the important hot path stuff into the first chunk, and then load other chunks as needed. With dynamic loading you can further make sure that additional chunks load out of the hot path, after first paint/first interaction/DOM ready/whatever else.
So this static async bundle creation helps ensure that you are only shipping what you need on initial download.
import('./myComponent').then(myComponent => /* ... */)
Or: const myComponent = await import('./myComponent')
That quibble aside, it's also relatively powerful: const dynamicComponent = await import(/* webpackChunkName: "components" */ `./components/${componentType}/index`)