-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Right now lodash is used throughout various @wordpress
packages in this repo because it's convenient and handles a lot of mundane things/logic that aren't worth duplicating. However there is a cost to using it:
- Size:
lodash.min.js
is 73.3kb - Increased potential for conflicts with plugins/themes also using lodash.
For this issue, I'd like to propose that we eliminate lodash usage across all our repository packages to reduce/remove the cost incurred by it. To do so:
- Implement some sort of utility package used for wrapping and exporting specific lodash (while not depending on it as an external). Things like
_.kebabCase
or_.isPlainObject
might be good candidates for this package. Difficulty here would be how to name this package and clearly defining what goes in it (we don't want it becoming a "catch all" type of package. - Replace usage of lodash functions that can be implemented via native js and utilize the new "utils" package for others that have logic we don't want to duplicate in all
@wordpress/*
packages.
Initially, I've started with @wordpress/element
dependency here.
I'm willing to spearhead this and get it completed, but before I begin, here's some decisions that we should make to move forward on this issue:
-
Is removing
lodash
dependency something we want to do? Everywhere or just select packges? -
Should we create a new package to contain specific lodash functions (like
_.kebabCase
) that can be used where needed instead of lodash? If yes, what name should we give the package. What conventions should we describe for what is allowed in the package?