Skip to content

Remove lodash dependency from WordPress packages.Β #17025

@nerrad

Description

@nerrad

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:

  1. Is removing lodash dependency something we want to do? Everywhere or just select packges?

  2. 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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions