DEV Community

Discussion on: Dynamic module import with Stimulus JS

Collapse
 
leastbad profile image
leastbad

Woah, what!?

How does this actually work? Is it generating a second pack and downloading it somehow? Are we talking about a second HTTP request?

Is the dynamically imported module cached? That is, if my controller mounts twice (or I have many objects with a given controller) does it move any additional data over the wire?

Big picture... doesn't this make the larger discussion around complicated code-splitting techniques discussed by React developers entirely moot?

As usual, thanks for the brilliant tip.

Collapse
 
adrienpoly profile image
Adrien Poly

Yes it will make a second http call. Lots of magic to me on how this actually works...

Cache works in the same way as your main cache

Collapse
 
leastbad profile image
leastbad

I'm trying to get my head around why this isn't a bigger deal. Again, it would seem to make the masochistic steps React devs take to split code seem ridiculous and moot.

Surely it can't actually be this simple?