launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
79 stars 67 forks source link

Replace arrow functions with normal functions #144

Closed wojtekmaj closed 1 year ago

wojtekmaj commented 1 year ago

Requirements

Describe the solution you've provided

Shaves off a few bytes from the bundle by using normal functions instead of arrow functions which, the way they were defined, need to have const behavior unnecessarily simulated.

XieX commented 1 year ago

When we say "a few bytes", we talking 5-10, hundreds, thousands? I'll do some testing.

Gonna put a pin in this for now, but I am spending a little time with the SDK next week, and will commit to seeing what I can do about the bundle size for you while I'm at it. Appreciate all of the suggestions you've given us 🏆

wojtekmaj commented 1 year ago

About 60 per instance.

https://babeljs.io/repl#?code_lz=MYewdgzgLgBArhApgMQDYEMDmEYF4YAUAlHgHwwDeAvgNwBQdiAHgA4gBOsAJogGbpxUsBCgzYaQA&fileSize=true

https://babeljs.io/repl#?code_lz=KYDwDg9gTgLgBAE2AMwIYFcA29noHYDGMAlhHnOgM7ABimqA5pQBQCUcA3gL5A&fileSize=true

XieX commented 1 year ago

Yeah, based on my testing we'd shave off about 200 bytes (compressed) in total. Not what I was hoping for, but it's not nothing! For the sake of minimizing merge conflicts though I'm going to close this PR and migrate these opportunistically in the work I'm currently doing. Thanks again for pointing it out, every day's a school day.