Hacker News new | ask | show | jobs
by bigjoemuffaraw 1420 days ago
I think when javascript is used to build html styles you end up with lots of files full of strings and boilerplate. I noticed a similar thing when I was using pixi.js for a small 3d scene. The build output was dominated by massive strings containing all of the shader code. I think once you decide on a style for your project its a good time to fork these libraries and tear out everything you aren't using.
2 comments

> tear out everything you aren't using

I was under the impression that production builds often include tree-shaking/dead-code-elimination as one of the steps?

There's a lot of "gotchas" when it comes to tree shaking in the JS ecosystem (not using the correct export style, having to do commonjs vs esm, what browser target you want like es3 vs es5 vs es2018 vs esnext), it also depends on the libraries you are pulling and if they're following practices to minimize outputs as well.

This is a decent article that discusses the basic strategies:

https://www.smashingmagazine.com/2021/05/tree-shaking-refere...

But basically tree shaking and dead code elimination can only be effective as the code you write. If you make it hard to parse with ASTs, it's going to hard to tree shake.

Doesn't this mean you can't ever easily upgrade again? You have to re-fork and re-strip-out-the-things every time there's an upstream update?