gmcquistin / react-throttle

80 stars 8 forks source link

Are you loading the entire lodash library? #5

Open artboard-studio opened 7 years ago

artboard-studio commented 7 years ago

Hi

Is this plugin loading the entire lodash library? Any way to avoid that and just load the necessary things?

gmcquistin commented 7 years ago

Yes, in https://github.com/gmcquistin/react-throttle/blob/master/src/classes/processors/Base.js

If you raise a PR for that, I could merge it in. Or I can do it myself when I have a spare moment. :)

Thank you!

MoOx commented 7 years ago

I am seeing the same in my project

screen shot 2017-02-01 at 17 18 03

I am not familiar with lodash. Who can we improve this?

Source: https://github.com/th0r/webpack-bundle-analyzer

artboard-studio commented 7 years ago

@MoOx lodash.js is basically the same as underscore.js which are both utility belts for javascript (array and object etc. helper functions) which in my opinion are becoming redundant with all the new cool stuff added in ES6 and ES7 (though still some useful functions could be found in lodash.js or underscore.js)

The way to improve react-throttle library is to use only the debounce throttle functions that could found here instead of using a huge library like lodash.js just for these two functions. Unfortunately, I still haven't found the time to raise a PR for it, but the present library is the best one available for using throttle-debounce in react since it could get very tricky doing it manually.

By the way, which tool did you use to generate your screenshot? Seems to be useful.

MoOx commented 7 years ago

https://github.com/th0r/webpack-bundle-analyzer

MoOx commented 7 years ago

I see multiple places that use lodash https://github.com/gmcquistin/react-throttle/search?utf8=✓&q=lodash

I think we should directly cherry pick modules.

gmcquistin commented 7 years ago

Thanks for the feedback, guys. I will work on this soon and raise a PR for you guys to review.

yoadsn commented 7 years ago

@gmcquistin Since you are already transpiling with babel, consider using babel-plugin-lodash and it will do the cherry picking automatically for you during build time..