DEV Community

Discussion on: 14 functions I made to dump lodash and reduce my bundle size...

Collapse
 
6temes profile image
Daniel

So... What is exactly the difference between using functions from Lodash and using your own function? Is your code lighter than Lodash just because you wrote it?

Collapse
 
miketalbot profile image
Mike Talbot ⭐

Well see above, partly down to the fact that I wrote tighter implementations with only the functionality I needed but a lot down to the face I used the same bundler to add polyfills I already need for the ones there. The different was around 22kb reduction from the tree shaken version. TBH debounce is probably the killer in there. But there are lots of "BaseClone" etc. Code that would work anywhere but I certainly don't use.

As you can see, this isn't all of lodash-es... so tree shaking worked as far as possible:

Build Analysis

Collapse
 
6temes profile image
Daniel • Edited

Then, to be fair, you didn't write functions that would replace Lodash. You wrote functions that offer a subset of the functionality offered by Lodash, and that's why they are lighter.

But something that it's true is that it would be really nice if they released a version 5 of Lodash that would be compatible only with evergreen browsers. I am sure that they could get rid of a lot of code.

Thread Thread
 
miketalbot profile image
Mike Talbot ⭐

Yeah I did document above which functions didn't work the same. Debounce, get and set basically. I don't have the need for the advanced versions of those.