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
@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
@ak How many is too many in terms of HTTP requests?
=> More informations about this toot | More toots from bw@social.lol
@bw with http3 should not really be an issue
=> More informations about this toot | More toots from ak@mastodon.social
@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
@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
@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
@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
@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
@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
@bw Also related: https://csswizardry.com/2023/07/the-http1liness-of-http2/
=> More informations about this toot | More toots from knowler@sunny.garden
@knowler Ah yeah, that was helpful.
=> More informations about this toot | More toots from bw@social.lol
@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
@teleclimber About a dozen I’d say.
=> More informations about this toot | More toots from bw@social.lol This content has been proxied by September (3851b).Proxy Information
text/gemini