[wp-trac] [WordPress Trac] #43733: Replace Underscores.js with Lodash.js

WordPress Trac noreply at wordpress.org
Tue Apr 21 13:34:11 UTC 2020


#43733: Replace Underscores.js with Lodash.js
--------------------------------------+------------------------------
 Reporter:  ChopinBach                |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  External Libraries        |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  dev-feedback needs-patch  |     Focuses:  javascript
--------------------------------------+------------------------------

Comment (by aduth):

 If I recall correctly, it should be a generally low-risk effort.
 Underscore and Lodash are very similar tools, and in a large number of
 cases share an identical API. Sometimes there are small differences in
 naming.

 Also mentioned in the original ticket, Lodash has a migration guide here:

 https://github.com/lodash/lodash/wiki/Migrating

 In the past, I've observed some specific differences that can be more
 subtle and cause some issues:

 https://github.com/WordPress/gutenberg/issues/4043#issuecomment-361049257

 Generally speaking, there should be a fairly straight-forward transition
 for the majority of usage.

 Personally, I think the value of undertaking the effort should be
 considered, or at least targeting specific core scripts which currently
 depend on Underscore, and where there's a high value of migrating to
 Lodash. What comes to mind for me is reducing the chances that both Lodash
 and Underscore would be loaded on the same page in a default installation
 of WordPress. For example, it can be seen on the post editor screen that
 both are loaded (noted in comment above).

 My suggestion would be to focus on those packages first. It's a bit hard
 to pinpoint, since anything which indirectly depends on Underscore will
 cause it to be loaded. Unless I'm unaware of some better option, it may
 require some close inspection of the `$wp_scripts` global to see how those
 dependencies are resolved. It might be a good first task to identify and
 prioritize those dependencies.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43733#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list