Reputation: 1909
Why individually importing lodash
functions weigh more than loading the whole library at once (top line)?
The whole library cost 71.5k but individually importing some functions weigh around 162k. What's the reason?
Upvotes: 2
Views: 492
Reputation: 105
There are a lot of mutual dependencies (mutual code that they all share) between those individual imports. The extension that you are using is most likely evaluating the weights of the imports with that mutual code for every single function separately. That ends up increasing the count for individual imports. Modern bundlers will ensure mutual code stays mutual; importing individual functions should still be more efficient.
Upvotes: 4