Live data from Hacker News

My failed attempt to shrink all NPM packages by 5%

evanhahn.com

71–80 of 253 posts

Re: My failed attempt to shrink all NPM packages by 5%

#71
post #25

Last I checked npm packages were full of garbage including non-source code. There's no reason for node_modules to be as big as it usually is, text compresses extremely well. It's just general sloppiness endemic to the JavaScript ecosystem.

At least, switch to pnpm minimize the bloat

I just installed a project with pnpm about 120 packages mostly react/webpack/eslint/redux related

with prod env: 700MB

without prod env: 900MB

sadly the bloat cannot be avoided that well :/

Re: My failed attempt to shrink all NPM packages by 5%

#72
post #21
post #10

Earlier quoted context omitted.

I feel massively increasing publish time is a valid reason not to push this though considering such small gains and who the gains apply to.

I agree, going from 1 second to 2.5 minutes is a huge negative change, in my opinion. I know publishing a package isn't something you do 10x a day but it's probably a big enough change that, were I doing it, I'd think the publish process is hanging and keep retrying it.

If you’re working on the build process itself, you’ll notice it a lot!

Re: My failed attempt to shrink all NPM packages by 5%

#73
post #25

Last I checked npm packages were full of garbage including non-source code. There's no reason for node_modules to be as big as it usually is, text compresses extremely well. It's just general sloppiness endemic to the JavaScript ecosystem.

You might be interested in e18e if you would like to see that change: https://e18e.dev/ They’ve done a lot of great work already.

Does this replace ljharb stuff?

Re: My failed attempt to shrink all NPM packages by 5%

#74

The fact that you are pursuing this is admirable. But this whole thing sounds too much like work. Finding opportunities, convincing entrenched stakeholders, accommodating irrelevant feedback, pitching in meetings — this is the kind of thing that top engineers get paid a lot of money to do. For me personally open source is the time to be creative and free. So my tolerance for anything more than review is very low. And…

The problem is that this guy is treating open source as if it was a company where you need to direct a project to completion. Nobody in open source wants to be told what to do. Just release your work, if it is useful, the community will pick it up and everybody will benefit. You cannot force your improvement into the whole group, even if it is beneficial in your opinion.

> where you need to direct a project to completion

Do you want to get a change in, or not?

Is this a project working with the community or not?

> Just release your work

What motivation exists to optimize package formats if nobody uses that package format? There are no benefits unless it’s in mainline.

> Nobody in open source wants to be told what to do

He’s not telling anybody to do work. He is sharing an optimization with clear tradeoffs - not a new architecture.

> You cannot force your improvement into the whole group

Nope, but communication is key. “put up a PR and we will let you know whether it’s something we want to pursue”.

Instead they put him through several levels of gatekeepers where each one gave him incorrect feedback.

“Why do we want to optimize bandwidth” is a question they should have the answer to.

If this PR showed up on my project I would say “I’m worried about X,Y,Z” we will set up a test for X and Y and get back to you. Could you look into Z?

Re: My failed attempt to shrink all NPM packages by 5%

#75
post #32

Earlier quoted context omitted.

> I don't find the cons all that compelling to be honest I found it reasonable. The 5% improvement was balanced against the cons of increased cli complexity, lack of native JS zopfli implementation, and slower compression .. and 5% just wasn't worth it at the moment - and I agree. >or at least I think they warrant further discussion I think that was the final statement.

Yes, but there’s a difference between “this warrants further discussion” and “this warrants further discussion and I’m closing the RFC”. The latter all but guarantees that no further discussion will take place.

No it doesn't. It only does that if you think discussion around future improvements belongs in RFCs.

Re: My failed attempt to shrink all NPM packages by 5%

#76
post #23
post #18

Earlier quoted context omitted.

50% size savings isn't important to the people who pay for it. They pay at most pennies for 100% savings (that is somehow all the functionality in zero bytes - not worth anything to those paying the bills)

Size savings translates to latency improvements which directly affects conversion rates. Smaller size isn’t about reducing costs but increased revenue. People care.

Note that this proof-of-concept implementation saves latency on first load, but may add latency at surprising points while using the website. Any user invoking a rarely-used function would see a delay before the javascript executes, without the traditional UI affordances (spinners etc) to indicate that the application was waiting on the network. Further, these secretly-slow paths may change from visit to visit. Many users know how to "wait for the app to be ready," but the traditional expectation is that once it's loaded, the page/app will work, and any further delays will be signposted.

I'm sure it works great when you've got high-speed internet, but might break things unacceptably for users on mobile or satellite connections.

Re: My failed attempt to shrink all NPM packages by 5%

#77
post #12

Props to anyone who tries to make the world a better place. Its not always obvious who has the most important use cases. In the case of NPM they are prioritizing the user experience of module authors. I totally see how this change would be great for module consumers, yet create potentially massive inconvenience for module authors. Interesting write-up

I think "massive" is overstating it. I don't think deploying a new version of a package is something that happens many times a day, so it wouldn't be a constant pain point. Also, since this is a case of having something compressed once and decompressed potentially thousands of times, it seems like the perfect tool for the job.

Every build in a CI system would probably create the package.

This is changing every build in every CI system to make it slower.

Re: My failed attempt to shrink all NPM packages by 5%

#78

The fact that you are pursuing this is admirable. But this whole thing sounds too much like work. Finding opportunities, convincing entrenched stakeholders, accommodating irrelevant feedback, pitching in meetings — this is the kind of thing that top engineers get paid a lot of money to do. For me personally open source is the time to be creative and free. So my tolerance for anything more than review is very low. And…

> What’s a little sad, is NPM should not be operating like a company with 1000+ employees. The “persuade us users want this” approach is only going to stop volunteers. They should be proactively identifying efforts like this and helping you bring it across the finish line.

Says who?

Says an engineer? Says a product person?

NPM is a company with 14 employees; with a system integrated into countless extremely niche and weird integrations they cannot control. Many of those integrations might make a professional engineer's hair catch fire - "it should never be done this way!" - but the real world is that the wrong way is the majority of the time. There's no guarantee that many of the downloads come from the official client, just as one example.

The last thing they need, or I want, or any of their customers want, or their 14 employees need, is something that might break backwards compatibility in an extremely niche case, anger a major customer, cause countless support tickets, all for a tiny optimization nobody cares about.

This is something I've learned here about HN that, for own mental health, I now dismiss: Engineers are obsessed with 2% optimizations here, 5% optimizations there; unchecked, it will literally turn into an OCD outlet, all for things nobody in the non-tech world even notices, let alone asks about. Just let it go.

Re: My failed attempt to shrink all NPM packages by 5%

#79

My experiment on how to reduce javascript size of every web app by 30-50% : https://github.com/avodonosov/pocl Working approach, but in the end I abandoned the project - I doubt people care about such js size savings.

How do you evaluate call usage?

Re: My failed attempt to shrink all NPM packages by 5%

#80

My experiment on how to reduce javascript size of every web app by 30-50% : https://github.com/avodonosov/pocl Working approach, but in the end I abandoned the project - I doubt people care about such js size savings.

I think this is called tree shaking and Vite/Rollup do this by default these days. Of course, it's easy when you explicitly say what you're importing.
Post reply on HN