user91579631 user91579631 - 1 year ago 151
Node.js Question

Require small section of lodash to minimize size

I am using browserify on lodash and discovered that lodash made up a significant chunk of the browserified


I imported in the entire lodash but I mainly use the
method so far.

var lodash = require('lodash');

How can I import only the necessary part of lodash to keep
small? I am using node.js v6

Answer Source

Take note that there are differences when you call lodash functions depending on how you import lodash.

var lodash = require('lodash');
var clone = lodash.cloneDeep(obj);

If you do cherry-picking as John-David Dalton suggests, you need to call the function this way.

var lodash_clonedeep = require('lodash/cloneDeep');
var clone = lodash_clonedeep(obj);

The experts may overlook the possibility that newbies may not know the correct way to call the lodash functions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download