by thex10 · 3y ago · 0 comments
> We found that react-icons had an issue that lead to everything being imported. This meant that we were including every single react-icon in our package whether we need it or not.
Kudos to the Linen team for proactively finding this - I have a feeling tons of projects blindly trust that tree-shaking their dependencies will "just work" even though for many libraries it won't!
> We also noticed that we were only using AWS client for s3 upload on the client side and it was taking up significantly more bundle size we need so we replaced the entire client side package with a 2 api calls to the AWS api.
For such a minimal use case, this feels like a logical choice even if it's slightly more work to implement.
> We ended up moving the code highlight code to a backend api that would cache the results.
Love seeing websites make smart choices about which work to handle in the server versus the client.
They provide a full framework but you can also download SVGs.
ex, an s3 only Java sdk:
https://stackoverflow.com/questions/35591248/aws-sdk-for-s3-...
You need to have two calls at least, generate a signed URL and then actually uploading it. How many lines on the client would you guess that requires? My guess is less than 30, and you cover 100% of your use case without putting in any 3rd party code what so ever. Sounds like a solid win with few drawbacks.
Any possibility of you sharing your "codemod script" so others can potentially implement it too? :)
For one particular microsoft product, this is brought to attention by documentation: https://learn.microsoft.com/en-us/power-apps/developer/compo...
Is there an easier way to verify this than, say, observing the final bundle size and looking inside the JS bundle? I'm not a frontend developer so this is outside my usual area of knowledge.
[source-map-explorer]: https://github.com/danvk/source-map-explorer
[Lighthouse Treemap]: https://umaar.com/dev-tips/270-devtools-lighthouse-treemap/
I notice that if I lower the bar and allow half baked hackish solutions to slip in, beyond some point, upkeep consumes infinite time. There seems no way back from that besides starting from scratch.
There is no good reason for front end things to break. I can only think of document.writeln() but who in his right mind...
The intro community discussion page at https://www.linen.dev/s/linen does need to load 20+ javascript files for some reason to show the latest messages.
Whereas messages still show up even if javascript is entirely blocked, just starting from the beginning in 10/2022 (?).
So I'm not quite sure if it's as optimized as it can be.
What tool did they use: Browserify, Webpack, Gulp, Rollup, Babel, Parcel, ESBuild, etc.
And this looks like the PR for the icons update: https://github.com/Linen-dev/linen.dev/pull/1001
Always fascinated when I hear that JS term for what's essentially dead code elimination.
Tree shaking only looks at the imports and removes code that isn't imported from the bundle. If code is imported but not executed, then tree shaking won't remove this code, even though it is dead code.
Using a different term is reasonable to avoid confusion, in this case.