Hacker News new | ask | show | jobs
by kaoD 2365 days ago
> a lot of those files will already be cached in the user's browser from CDNs anyway

Not anymore.

https://www.jefftk.com/p/shared-cache-is-going-away

1 comments

Interesting.

That means that the module approach isn't faster than bundling, but with HTTP2, the module approach shouldn't be slower than bundling.

Bundling also deletes dead code so it can potentially save a lot, especially if you import huge libraries and only use a small part of them.
Can you give an example of a bundler that removes dead code and not just minifies it? Dead code removal in JS is a bit tricky, unless we are only talking about code after return statements and other low hanging fruit.
IIRC as long as you use ES modules, tree-shaking is trivial?

EDIT: not that trivial https://webpack.js.org/guides/tree-shaking/

Hmm. Now that we have async functions meybe we could also add the pure keyword in order to help optimizations.
A much better solution is to not import huge libraries you will only use a small part of.