Ancestors

Toot

Written by Blake Watson :prami: on 2025-01-21 at 19:03

Does anyone know what the current best practice is for using ES modules in the browser? How many is too many in terms of HTTP requests?

=> More informations about this toot | More toots from bw@social.lol

Descendants

Written by AK on 2025-01-21 at 19:07

@bw You can do it, with or without a bundler, and with or without a module map

=> More informations about this toot | More toots from ak@mastodon.social

Written by Blake Watson :prami: on 2025-01-21 at 19:08

@ak How many is too many in terms of HTTP requests?

=> More informations about this toot | More toots from bw@social.lol

Written by AK on 2025-01-21 at 19:15

@bw with http3 should not really be an issue

=> More informations about this toot | More toots from ak@mastodon.social

Written by Jared “Indie Social Web” White on 2025-01-21 at 19:12

@bw do you mean like buildless, locally? or pulling from an ES-friendly CDN?

If the latter, I recommend either esm.sh, or jsdelivr (ESM version).

If the former, it's more tricky to be sure. I think buildless is a bit of a pipe dream, and I always reach for esbuild, which makes it very easy to go from local node_modules to output bundles with a minimum of fuss (and it's very fast!).

=> More informations about this toot | More toots from jaredwhite@indieweb.social

Written by Blake Watson :prami: on 2025-01-21 at 19:49

@jaredwhite I’m mostly talking about first-party modules. For example, I have a project with about a dozen first-party modules and 3 not-too-big libs. If I pull all that in from my local server, is that fine, or am I (well, the person visiting) paying a performance cost?

Esbuild is nice, I agree. I’m just wondering how far I can go without a build before it’s problematic.

=> More informations about this toot | More toots from bw@social.lol

Written by Jared “Indie Social Web” White on 2025-01-21 at 19:52

@bw worth a close look at the network tab…I think anything that's in the low 100kb or less in total (uncompressed, hopefully you can serve Brotli or Gzip) is OK, but I'd try to make sure none of it is blocking — aka HTML loads in fine first and JS can init later.

=> More informations about this toot | More toots from jaredwhite@indieweb.social

Written by Blake Watson :prami: on 2025-01-21 at 19:58

@jaredwhite Yeah that’s good advice. Unfortunately in my specific case, the DOM needs to be rendered with JavaScript.

It’s an app that must work as a webpage and a browser extension. Bundling would probably speed up the web page, but it’s discouraged by extension guidelines. But I might be able to bundle only the web version.

=> More informations about this toot | More toots from bw@social.lol

Written by Jared “Indie Social Web” White on 2025-01-21 at 20:11

@bw ah, that's an oddball I guess. Yeah, might be that you can use something like esbuild just on the web version to trim off some of the fat.

=> More informations about this toot | More toots from jaredwhite@indieweb.social

Written by Nathan Knowler on 2025-01-21 at 19:17

@bw This isn’t ESM specific, but could be helpful. https://csswizardry.com/2023/10/the-three-c-concatenate-compress-cache/

=> More informations about this toot | More toots from knowler@sunny.garden

Written by Nathan Knowler on 2025-01-21 at 19:22

@bw Also related: https://csswizardry.com/2023/07/the-http1liness-of-http2/

=> More informations about this toot | More toots from knowler@sunny.garden

Written by Blake Watson :prami: on 2025-01-21 at 20:09

@knowler Ah yeah, that was helpful.

=> More informations about this toot | More toots from bw@social.lol

Written by Olivier Forget on 2025-01-21 at 19:18

@bw I think as long as you're serving over http2 or better you should be OK? How many modules are you pulling individually?

Note: I haven't experimented myself, but I'm interested in the question.

=> More informations about this toot | More toots from teleclimber@social.tchncs.de

Written by Blake Watson :prami: on 2025-01-21 at 19:50

@teleclimber About a dozen I’d say.

=> More informations about this toot | More toots from bw@social.lol

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113867898200399959
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
350.063074 milliseconds
Gemini-to-HTML Time
2.211251 milliseconds

This content has been proxied by September (3851b).