Yes I didn't emphasize on it. You are right, this is a Webpack feature (probably also supported by other bundlers as it is a JS feature developer.mozilla.org/en-US/docs/W...).
The nice thing with Stimulus is that it pairs very well with the lifecycle events.
Actually you can do it anywhere with webpack, not only Stimulus.
Thanks for quick tip!
Yes I didn't emphasize on it. You are right, this is a Webpack feature (probably also supported by other bundlers as it is a JS feature developer.mozilla.org/en-US/docs/W...).
The nice thing with Stimulus is that it pairs very well with the lifecycle events.
Indeed, forgot that browser modules have native support for dynamic imports.
Just found this, so I'm a little late to the party, but rollup also has first class support for dynamic imports.
rollupjs.org/guide/en/#code-splitting