stampit-org / stampit

OOP is better with stamps: Composable object factories.
https://stampit.js.org
MIT License
3.02k stars 102 forks source link

Reducing size even more #323

Closed koresar closed 6 years ago

koresar commented 7 years ago

Recently @ericelliott posted a truly great concern that we are bloating stampit: https://github.com/stampit-org/stampit/pull/320#issuecomment-325812185

I agree, we should save those bytes (lines of code). I would even add that we should simplify stampit infrastructure because it was overly complexified with ES6->ES5 compilation.

Current stampit UMD build size is 5.26 KB. By removing fancy ES6 stuff (plus some optimization techniques) I managed to reduce the size down to 4.0 KB.

To be precise: 5393 -> 4128 bytes. It is 1,265 bytes or 23.5% less.

Simultaneously, this will fix #317, which was reported three times IIRC. (TL;DR: our own examples do not work in browsers.)

Also, this will reduce devDepencencies a bit.

Pinging all people from the #320 discussion: @sethlivingston @FredyC @Mustack @jyboudreau @ericelliott

Should I proceed and submit the PR?

koresar commented 7 years ago

New result: 3931 bytes.

stampit.umd.min.js: 5393 -> 3931 bytes. It is 1462 bytes or 27.1% less. 5.26 KB ->3.8 KB`

(Btw, GZIP: 1.84 KB -> 1.77 KB. Or 1906 -> 1790 bytes.)

Changes.

koresar commented 7 years ago

So, I went crazy today.

New result: 3168 bytes. The performance did not suffer, even increased!

stampit.umd.min.js: 5393 -> 3168 bytes. It is 2225 bytes or 41.3% less. 5.26 KB -> 3.09 KB

(Btw, GZIP: 1.84 KB -> 1.54 KB. Or 1906 -> 1578 bytes.)

Code become less readable though.

koresar commented 6 years ago

New new result: 2885 bytes. The performance is the same.

stampit.umd.min.js: 5393 -> 2885 bytes. It is 2508 bytes or 46.5% less. 5.26 KB -> 2.82 KB

GZIP: 1.84 KB -> 1.36 KB. Or 1906 -> 1395 bytes.

JosephClay commented 6 years ago

Those are some impressive gains

koresar commented 6 years ago

This is what stampit is currently:

image

koresar commented 6 years ago

Thinking of releasing stampit v4:

As the result stampit and @stamp/* modules will become fully compatible.

koresar commented 6 years ago

After size reduction the tests run fine in IE11: image

koresar commented 6 years ago

Using stamp-specification v1.5. New new result: 2761 bytes. The performance is the same.

stampit.umd.min.js: 5393 -> 2761 bytes. It is 2632 bytes or 49% less. 5.26 KB -> 2.70 KB

GZIP: 1.84 KB -> 1.29 KB. Or 1906 -> 1322 bytes.