Are ES6 modules in browsers going to get loaded level-by-level?

#!/JoePea joe at trusktr.io
Mon Oct 12 20:14:20 UTC 2020


Right, exactly. So naively sending all dependencies wastefully is just
the first step.

> Afaik the more promising path are prefetch hints on the client. E.g. the
client (or initial HTML payload) knows the dependency tree, adds tags
for preloading the required modules, and then the browser can properly
handle fine-grained caching from there, only requesting what is actually
needed.

That may be nice, but I imagine people importing libraries from
different domains (without knowing the graphs, for example, in simple
codepen or jsfiddle demos with no build tooling).

So suppose the client code consists only of one single line of HTML, just

```html
<script type=module src="./path/to/module.js">
```

In this case, the ES-module-aware server needs to just send everything
wastefully, because there's no way to know what not to send.

Optimizations requirements aside, are there any HTTP/2 servers that
are es-module-aware?

#!/JoePea

On Mon, Oct 12, 2020 at 1:06 PM Jan Krems <jan.krems at gmail.com> wrote:
>
> > If I understand HTTP/2 correctly, this requires more than a server
> > that simply has HTTP push, it requires a server that understands how
> > to read ES modules and enumerate their dependencies.
>
> Not only that: The server also has to "know" which modules are already
> cached by the client (including potential match/modified-since logic). If
> the server always sends _all_ modules in the dependency graph, then it's
> just a less efficient bundle of all modules.
>
> Afaik the more promising path are prefetch hints on the client. E.g. the
> client (or initial HTML payload) knows the dependency tree, adds tags
> for preloading the required modules, and then the browser can properly
> handle fine-grained caching from there, only requesting what is actually
> needed.
>
> Cheers,
> Jan
>
> On Mon, Oct 12, 2020 at 12:59 PM #!/JoePea <joe at trusktr.io> wrote:
>>
>> I'm asking about a server that, upon request of a `.js` file, knows
>> how to enumerate the dependency tree based on that file, _then_ HTTP
>> pushes all the modules at once.
>>
>> So basically, from the code
>>
>> ```html
>> <script type=module src="./path/to/module.js">
>> ```
>>
>> the client knows it should request `./path/to/module.js`, but it does
>> not know what modules that `./path/to/module.js` will want to import
>> because the source code has not yet arrived.
>>
>> So what I am imagining is the server receives the request for
>> `./path/to/module.js`, _and_ it enumerates the dependencies of
>> `./path/to/module.js` and also pushes those.
>>
>> If I understand HTTP/2 correctly, this requires more than a server
>> that simply has HTTP push, it requires a server that understands how
>> to read ES modules and enumerate their dependencies.
>>
>> So what I wondering is if there are any servers that do that.
>>
>> #!/JoePea
>>
>> On Sun, Oct 11, 2020 at 1:26 PM Isiah Meadows <contact at isiahmeadows.com> wrote:
>> >
>> > Have you actually tried to test it? HTTP Push is more a server thing than a browser thing.
>> > -----
>> >
>> > Isiah Meadows
>> > contact at isiahmeadows.com
>> > www.isiahmeadows.com
>> >
>> >
>> > On Sat, Oct 10, 2020 at 5:51 PM #!/JoePea <joe at trusktr.io> wrote:
>> >>
>> >> It's 5 years later, but still no (obvious) sign of HTTP/2 servers specialized in ES Module push.
>> >>
>> >> Do any exist? Anyone have a list? I'm especially interested in the self-hostable servers, but also curious about solutions where we may publish modules to.
>> >>
>> >> The non-self-hosted solutions may be attractive to those people who normally publish static sites and need to publish ES Modules as static resources somewhere without the fuss if managing a server.
>> >>
>> >> #!/JoePea
>> >> _______________________________________________
>> >> es-discuss mailing list
>> >> es-discuss at mozilla.org
>> >> https://mail.mozilla.org/listinfo/es-discuss
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list