-
Notifications
You must be signed in to change notification settings - Fork 2k
i18n-calypso: Replace EventEmitter with simplified subscriber callbacks #103304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~134 bytes removed 📉 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~241 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~51 bytes removed 📉 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
Proposed Changes
i18n-calypso
package, substituting a simplified subscriber implementationWhy are these changes being made?
EventEmitter
data approach toward conventions more conventional and compatible with React (e.g.useEffect
subscribers)events
package in common dependency (estimated 2kb gzipped)On performance, I discovered that the
events
library does have a surprisingly-performant subscriber removal behavior. Early iterations here included a "readable"Array#filter
implementation (see a8fb2d4), but considering that many of our localized components will remove event listeners once they're unmounted, it seemed worthwhile to micro-optimize. After several rounds of micro-benchmarking, I found a solution which performs even better (~38%) thanevents
's implementation, and ~850x better than a naiveArray#filter
implementation in a scenario with 2000 subscribers.Separately, I had explored an implementation which largely maintained the same API if we'd rather reduce the scope of the changes.
Testing Instructions
Pre-merge Checklist