Hacker News new | ask | show | jobs
by m8s 1091 days ago
> Svelte 4 reduces the Svelte package size by nearly 75% (10.6 MB down to 2.8 MB), which means less waiting on npm install. This improvement will be especially noticeable for users who are loading our interactive learning experience on learn.svelte.dev for the first time, users of the Svelte REPL, and users with limited connectivity. The majority of the remaining package size is eslint support, which necessitates distributing a CJS build, and once the eslint rewrite is completed the Svelte package size can drop by over another 50%.

Wow, that’s a pretty big reduction.

6 comments

Speaking about size reduction, I once had a client who want me to update his product as it became extremely slow and buggy. The product was an MS Word Add-In that was run on an MS Surface which takes shots using webcam and insert them into the active document, it was built in .Net and the previous developer used, as I recall, OpenCV library to take the shots. The installation binary was around 300MB! And, to add insult to injury, both x86 & x64 of OpenCV were included in binary which made the final binary more than 600MB. I then used a tiny lib in C# to take webcam shots and rebuild the entire solution from scratch which generated a binary of around 1MB. The client had some concerns and suspicions about my delivery but once he tried it in a clean Surface, he realized what I did. It was like magic for him but not for me. I was happy because I made him happy :)
> clean Surface

Eh, that's not a fair comparison, Windows bundles the .NET standard libraries and runtime.

I might misused the term clean surface, I do not mean a fresh OS install but a surface tablet that hadn’t the old product installed so he can confirm my product do not use any of dependencies of the previous one.
How old was the Add-In? Did the tiny lib you used exist back then and did it support the Surface webcam?
The tiny lib was just a wrapper around some Windows API I guess to read shots from the webcam stream. Also, this lib is not specifically designed for surface laptops/tablets, it was generic, I used a Logitech webcam on dev PC and it worked just fine.
I find it funny how you‘ve gotten a few questions about feature parity, rather than how someone could ever use 300MB for just taking a selfie.
I remember when I was talking about some code my team wrote once and we'd managed to get an operation down from 6 hours to like 5 minutes.

Another manager said to me (fairly with hindsight) "If you get something down from two hours to one hour, that's an opimisation. Going from 6 hours to 5 minutes means it just wasn't finished."

Finishing a project is one hell of an optimization, I suppose!
I hope you glared at him and said "do I need to optimize your ass with my foot?"

Sorry, HR rep, I thought we were just slinging pithy aphorisms!

I wonder how much of that came from this TS to JSDoc change Rich Harris talked about here: https://news.ycombinator.com/item?id=35892250

> I _would_ say that this will result in no changes that are observable to users of the framework, but that's not quite true — it will result in smaller packages (no need to ship giant sourcemaps etc), and you'll be able to e.g. debug the framework by cmd-clicking on functions you import from `svelte` and its subpackages (instead of taking you to an unhelpful type declaration, it will take you to the actual source, which you'll be able to edit right inside `node_modules` to see changes happen).

A lot! Sourcemaps are often twice the size of the code itself.
Let's hope all baggage was not offloaded to some extra dependency ;) In all seriousness I would like to see more packages competing to reduce size and dependencies count to absolute minimum.
From the post

> The number of dependencies in Svelte has been greatly reduced from 61 down to 16. This means faster downloads for our users as well as less susceptibility to supply chain attacks

Its not zero but quite a big dependency reduction

I'm used to Svelte, and I remember last year when I tried to install a basic NextJS starter template (create-nextjs-app) I had to wait a minute or so for all the npm dependencies to install. I then checked my project folder and it was 600MB....mindblowingly bloated.
To be fair, react is < 0.5MB.

create-nextjs-app is installing React, React Router, Webpack, Tailwind, ESLint, Jest, etc.

create-nextjs-app is by design an "everything and the kitchen sink" approach.

yea but this more like install react more than nextjs, nextjs do to much magic to be comparable 600 mb is insane anyway but is important to be clear then we are comparing different things
Creating a skeleton SvelteKit app was around 150mb.
Would SvelteKit be a better comparison then?
Yes agree, SvelteKit is the better comparison.
Yes. Svelte:React::SvelteKit:NextJS
and totally irrelevant. how is having 600mb of dependencies making your life so much harder compared to time savings and developer experience Nextjs provides
I wouldn't say it's totally irrelevant...it translates to slow dev builds, slow dev startup, etc. Especially considering SvelteKit may be ~150 mb, but npm i is a couple seconds and npm run dev is basically instant. I'm biased because I'm allergic to React and anything JSX touches, including NextJS, so in all honesty I wouldn't use it if it was 1kb.
At this rate Svelte 5 is going to have to be renamed Anorexic!