cristianbote / goober

🥜 goober, a less than 1KB 🎉 css-in-js alternative with a familiar API
https://goober.rocks
MIT License
3.11k stars 118 forks source link

perf: apply optional chaining and an arguments->args change #561

Closed JoshuaKGoldberg closed 1 month ago

JoshuaKGoldberg commented 1 year ago

👋 hi! I just learned about this repo's performance challenge. Very fun. It's pretty optimized as-it-is, so most things I tried didn't result in any positive impact in goober.modern.js after gzipping locally.

But, I did find two changes that each showed small improvements locally:

Files created by running:

  1. npm run build
  2. gzip dist/goober.modern.js --best

Measurements taken by opening Get Info on Mac.

Change(s) goober.modern.js goober.modern.js.gz .gz Δ (bytes)
(baseline) 2,284 bytes 1,269 bytes (n/a)
Just _args 2,261 bytes 1,263 bytes -6 🟢
Just ?. 2,269 bytes 1,263 bytes -6 🟢
_args and ?. 2,250 bytes 1,260 bytes -9 🟢

Note: Optional chaining is implemented right now with typescript-eslint's @typescript-eslint/prefer-optional-chain. Which is a very silly, over-the-top way to get this to work... but all the alternatives I'd tried didn't work!

If you know a way to get optional chaining to work in an output bundle without installing four dev dependencies, please let me know!

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
goober-rocks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 13, 2023 4:21am
JoshuaKGoldberg commented 6 months ago

Ping @cristianbote, is the challenge still active? I enjoyed this PR, but it did take some time to get to. If this repo isn't active anymore I'd think it'd be best to make that clear.