Are ES6 modules in browsers going to get loaded level-by-level?
d at domenic.me
Thu Apr 16 19:18:05 UTC 2015
> Is there any mean in sight, that will allow us to serve
> them as fast as we can serve hundreds of bundled and minimized CJS
> modules now?
Yes. Any browser which implements the ES6 module loader (none of them right now) will also be a browser that implements HTTP/2 (all of them right now). HTTP/2 server push would allow you to respond to a single request for "entry.js" (e.g. from `<script type="module" src="entry.js"></script>`) with responses for all modules in the entire dependency graph, prioritized according to their level in the graph, all over a single TCP connection.
This is just the most naïve strategy I could think of with HTTP/2. There are more interesting ones too.
It's also important to note that bundling is an antipattern in the HTTP/2 world, as it prevents incremental cache updates by invalidating the entire bundle graph when you change a single file, and does not allow relative prioritization of individual files.
More information about the es-discuss