Post

During a perf audit for a client, I read this in a PR: "The module should only be loaded once, not every time a file is selected." When I read it, something didn't add up, so I started digging. And the result surprised me. I wrote a post joanleon.dev/en/dynamic-i... #JS #WebPerf

joanleon.devDynamic import(): the browser already caches our modules | Joan LeónCalling import() every time a feature is used doesn't download or evaluate the module again: the browser reuses it from its module map. What it guarantees, when the same module stops being the same, a...

1 repost4 likes

Useful reminder: import() is keyed by the resolved module URL in the page's module map. The subtle boundary is lifetime: repeated UI actions in one document can reuse it, while a full page reload creates a new document and module map. Good example of separating fetch cost from component lifecycle.