Skip to content
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

Ensure stepper declarative flow components tree-shake properly #90851

Merged
merged 1 commit into from
May 20, 2024

Conversation

sgomes
Copy link
Contributor

@sgomes sgomes commented May 17, 2024

This PR enables tree-shaking for the stepper declarative flow internal components sub-tree, so that only the required ones get put in the entry point chunk.

This appears to result in a massive reduction (160KB gzipped / over 500KB uncompressed) of the stepper entry-point, with the affected components moving instead to more specific chunks such as individual flows.

Proposed Changes

  • Add a package.json with "sideEffects": false to the stepper declarative flow internal components sub-tree

Why are these changes being made?

  • To move unnecessary code away from the entry point chunks, towards the chunks that actually need it

Testing Instructions

Smoke-test a few stepper flows and ensure that nothing breaks.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • N/A Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • N/A Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • N/A Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • N/A For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@sgomes sgomes changed the title Ensure stepper decl. flow components tree-shake Ensure stepper declarative flow components tree-shake May 17, 2024
@sgomes sgomes changed the title Ensure stepper declarative flow components tree-shake Ensure stepper declarative flow components tree-shake properly May 17, 2024
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~159537 bytes removed 📉 [gzipped])

name                   parsed_size            gzip_size
entry-stepper            -526393 B  (-19.0%)  -161533 B  (-21.4%)
entry-main                 +5628 B   (+0.3%)     +812 B   (+0.1%)
entry-domains-landing      +4029 B   (+0.6%)    +1037 B   (+0.6%)
entry-browsehappy          +4029 B   (+1.8%)    +1037 B   (+1.5%)
entry-login                +3915 B   (+0.3%)    +1019 B   (+0.2%)
entry-subscriptions        +3906 B   (+0.2%)    +2560 B   (+0.5%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~270093 bytes added 📈 [gzipped])

name                               parsed_size             gzip_size
link-in-bio-tld-flow                 +536321 B   (+46.7%)  +159892 B   (+48.3%)
write-flow                           +533049 B  (+357.3%)  +161218 B  (+341.7%)
build-flow                           +533049 B  (+363.1%)  +161218 B  (+347.5%)
videopress-flow                      +532896 B  (+101.7%)  +158960 B  (+100.6%)
import-flow                          +183303 B    (+6.9%)   +53901 B    (+7.1%)
import-hosted-site-flow               +96429 B   (+13.1%)   +25607 B   (+11.4%)
update-design-flow                    +82336 B    (+7.9%)   +23922 B    (+8.1%)
copy-site-flow                        +70699 B   (+12.1%)   +23886 B   (+13.7%)
sensei-flow                           +55322 B   (+11.1%)   +18576 B   (+12.5%)
podcasts-flow                         +54123 B   (+13.2%)   +18447 B   (+14.9%)
newsletter-post-setup-flow            +40082 B   (+53.8%)   +14261 B   (+56.4%)
link-in-bio-post-setup-flow           +40082 B   (+53.9%)   +14256 B   (+56.6%)
plugin-bundle-flow                    +14268 B    (+8.4%)    +4462 B    (+7.7%)
site-setup-flow                        +8204 B   (+13.2%)    +1023 B    (+8.2%)
assembler-first-flow                   +8113 B   (+12.8%)    +1109 B    (+8.4%)
ai-assembler-flow                      +8113 B   (+12.7%)    +1121 B    (+8.4%)
with-theme-assembler-flow              +8061 B   (+14.7%)    +1115 B   (+10.7%)
domain-user-transfer-flow              +7630 B    (+3.3%)    +2373 B    (+5.0%)
update-options-flow                    +6217 B   (+16.8%)     +547 B   (+10.9%)
trial-wooexpress-flow                  +6217 B   (+15.2%)     +543 B    (+8.3%)
site-migration-flow                    +6217 B   (+14.0%)     +552 B    (+7.3%)
migration-signup                       +6217 B   (+14.5%)     +548 B    (+7.8%)
hosted-site-migration-flow             +6217 B   (+13.9%)     +553 B    (+7.2%)
free-post-setup-flow                   +6217 B   (+17.0%)     +545 B   (+11.3%)
free-flow                              +6217 B   (+13.5%)     +549 B    (+6.8%)
entrepreneur-flow                      +6217 B   (+14.9%)     +590 B    (+8.6%)
transferring-hosted-site-flow          +5392 B   (+13.6%)    +2026 B   (+14.2%)
start-writing-flow                     +3954 B   (+21.2%)     +551 B   (+11.0%)
design-first-flow                      +3954 B   (+20.2%)     +543 B   (+10.5%)
signup                                 +3812 B    (+1.3%)     +187 B    (+0.3%)
videopress-tv-flow                     +2665 B    (+4.9%)    +1460 B    (+8.0%)
link-in-bio-flow                       +1834 B   (+11.5%)     +443 B    (+9.6%)
newsletter-flow                        +1740 B   (+10.1%)     +441 B    (+9.2%)
hundred-year-plan                      +1404 B    (+4.2%)     +354 B    (+3.5%)
security                               +1104 B    (+0.1%)     -352 B    (-0.1%)
stats                                   +768 B    (+0.1%)    -1989 B    (-0.6%)
a8c-for-agencies-marketplace            +753 B    (+0.1%)     -177 B    (-0.1%)
link-in-bio-flow-domain                 +671 B    (+2.4%)     +271 B    (+3.7%)
site-monitoring                         -588 B    (-0.1%)    -3810 B    (-1.2%)
settings-podcast                        +556 B    (+0.1%)    +1872 B    (+1.1%)
a8c-for-agencies-sites                  -536 B    (-0.0%)    -1246 B    (-0.3%)
google-transfer                         +528 B    (+9.8%)     +169 B    (+8.7%)
domain-transfer                         +528 B   (+10.3%)     +168 B    (+8.8%)
connect-domain                          +523 B    (+1.9%)     +164 B    (+2.2%)
reader                                  +501 B    (+0.1%)     +255 B    (+0.1%)
privacy                                 +488 B    (+0.1%)     +858 B    (+0.4%)
me                                      +488 B    (+0.1%)     +827 B    (+0.4%)
developer                               +488 B    (+0.1%)     +877 B    (+0.4%)
account-close                           +488 B    (+0.1%)     +914 B    (+0.4%)
site-blocks                             +477 B    (+0.1%)     +923 B    (+0.4%)
settings-security                       +461 B    (+0.1%)    -1307 B    (-0.8%)
posts                                   -434 B    (-0.1%)     -545 B    (-0.2%)
sites-dashboard                         -420 B    (-0.0%)    -3344 B    (-1.2%)
dev-tools-promo                         -420 B    (-0.0%)    -3345 B    (-1.2%)
backup                                  -400 B    (-0.0%)    -1433 B    (-0.4%)
tailored-ecommerce-flow                 +369 B    (+3.5%)     +136 B    (+4.1%)
reblogging-flow                         +369 B    (+4.6%)     +101 B    (+3.8%)
comments                                -364 B    (-0.0%)    -1660 B    (-0.7%)
gutenberg-editor                        +332 B    (+0.1%)     -298 B    (-0.2%)
github-deployments                      -327 B    (-0.0%)    -2464 B    (-0.8%)
people                                  -318 B    (-0.0%)    -2042 B    (-1.0%)
new-hosted-site-flow                    +316 B    (+4.1%)     +108 B    (+4.2%)
plans                                   -312 B    (-0.0%)     -331 B    (-0.1%)
help                                    +292 B    (+0.0%)     +883 B    (+0.4%)
pages                                   -290 B    (-0.1%)     -698 B    (-0.4%)
settings-performance                    +250 B    (+0.0%)     -117 B    (-0.1%)
posts-custom                            -240 B    (-0.0%)     -754 B    (-0.3%)
notification-settings                   +238 B    (+0.0%)     +197 B    (+0.1%)
jetpack-cloud-overview                  -204 B    (-0.0%)     -555 B    (-0.4%)
jetpack-cloud                           -204 B    (-0.0%)     -518 B    (-0.4%)
scan                                    -203 B    (-0.0%)     -254 B    (-0.1%)
checkout                                +200 B    (+0.0%)     +571 B    (+0.1%)
theme                                   -199 B    (-0.0%)     -610 B    (-0.3%)
marketplace                             +196 B    (+0.0%)     +957 B    (+0.3%)
settings-reading                        +188 B    (+0.0%)     +925 B    (+0.7%)
email                                   +188 B    (+0.0%)     +845 B    (+0.4%)
patterns                                +172 B    (+0.0%)     -641 B    (-0.1%)
settings-jetpack                        -155 B    (-0.0%)    -1590 B    (-0.9%)
a8c-for-agencies-purchases              -151 B    (-0.0%)     -418 B    (-0.3%)
jetpack-cloud-features-comparison       +134 B    (+0.0%)     +670 B    (+0.3%)
incoming-redirect                       +134 B    (+0.6%)     +336 B    (+3.8%)
concierge                               +131 B    (+0.0%)      -24 B    (-0.0%)
themes                                  -128 B    (-0.0%)     -388 B    (-0.1%)
a8c-for-agencies-referrals              -126 B    (-0.1%)     -604 B    (-1.0%)
a8c-for-agencies-overview               -126 B    (-0.1%)     -604 B    (-0.9%)
a8c-for-agencies-migrations             -126 B    (-0.1%)     -629 B    (-1.2%)
plugins                                 -125 B    (-0.0%)    -1903 B    (-0.3%)
google-my-business                      -120 B    (-0.0%)    -1297 B    (-0.8%)
domains                                 -120 B    (-0.0%)    +1097 B    (+0.2%)
jetpack-cloud-agency-sites-v2           -115 B    (-0.0%)     +795 B    (+0.2%)
activity                                -112 B    (-0.0%)     -878 B    (-0.4%)
purchases                               +109 B    (+0.0%)     +944 B    (+0.2%)
a8c-for-agencies-signup                 +109 B    (+0.1%)     +424 B    (+1.6%)
hosting                                 -104 B    (-0.0%)    -1752 B    (-0.4%)
jetpack-cloud-agency-signup             +103 B    (+0.2%)       -6 B    (-0.0%)
jetpack-cloud-settings                  -101 B    (-0.0%)    -1564 B    (-0.9%)
preview                                  -95 B    (-0.0%)      -98 B    (-0.1%)
add-ons                                  +95 B    (+0.0%)      -33 B    (-0.0%)
site-purchases                           -83 B    (-0.0%)     +854 B    (+0.2%)
purchase-product                         +83 B    (+0.1%)      +12 B    (+0.0%)
settings-discussion                      +81 B    (+0.0%)      -72 B    (-0.1%)
a8c-for-agencies-settings                +70 B    (+0.0%)     -248 B    (-0.5%)
settings                                 -68 B    (-0.0%)    -1604 B    (-0.7%)
home                                     +68 B    (+0.0%)     -983 B    (-0.2%)
a8c-for-agencies-plugins                 -64 B    (-0.0%)     -576 B    (-1.4%)
settings-writing                         -62 B    (-0.0%)      -56 B    (-0.0%)
promote-post-i2                          -62 B    (-0.0%)      -94 B    (-0.1%)
jetpack-connect                          -62 B    (-0.0%)      +68 B    (+0.0%)
jetpack-cloud-pricing                    -62 B    (-0.0%)      +75 B    (+0.0%)
jetpack-cloud-plugin-management          -48 B    (-0.0%)     -620 B    (-0.1%)
jetpack-cloud-partner-portal             +35 B    (+0.0%)     +202 B    (+0.1%)
media                                    -33 B    (-0.0%)      -29 B    (-0.0%)
import                                   -33 B    (-0.0%)    -1301 B    (-0.8%)
earn                                     +32 B    (+0.0%)    -1413 B    (-0.6%)
marketing                                +30 B    (+0.0%)      +80 B    (+0.0%)
site-profiler                            +29 B    (+0.0%)      -10 B    (-0.0%)
a8c-for-agencies-landing                 +29 B    (+0.0%)       -4 B    (-0.0%)
devdocs                                  +20 B    (+0.0%)      -27 B    (-0.0%)

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 (~5216 bytes added 📈 [gzipped])

name                                                                              parsed_size              gzip_size
async-load-automattic-search                                                         +28464 B  (+2360.2%)    +9706 B  (+1625.8%)
async-load-automattic-design-preview                                                 +15919 B     (+0.9%)    +5376 B     (+1.2%)
async-load-design                                                                     -3711 B     (-0.2%)    -3534 B     (-0.7%)
async-load-design-playground                                                          -3455 B     (-0.3%)    -1271 B     (-0.4%)
async-load-migration-success                                                          +2685 B    (+29.6%)     +824 B    (+25.3%)
async-load-calypso-my-sites-checkout-modal                                            +2069 B     (+0.2%)     +661 B     (+0.2%)
async-load-signup-steps-page-picker                                                    +687 B     (+0.2%)     +711 B     (+0.6%)
async-load-signup-steps-emails                                                         +687 B     (+1.1%)     +714 B     (+3.5%)
async-load-signup-steps-site-picker                                                    +593 B     (+0.6%)    +1276 B     (+4.2%)
async-load-signup-steps-difm-site-picker                                               +593 B     (+0.6%)    +1296 B     (+4.2%)
async-load-signup-steps-woocommerce-install-transfer                                   +304 B     (+0.9%)      +78 B     (+0.7%)
async-load-calypso-components-sites-popover                                            +279 B     (+0.4%)    +1246 B     (+5.3%)
async-load-design-blocks                                                               +270 B     (+0.0%)     -679 B     (-0.1%)
async-load-calypso-components-web-preview-component                                    +249 B     (+0.1%)     -480 B     (-0.4%)
async-load-signup-steps-plans-theme-preselected                                        -228 B     (-0.1%)     -510 B     (-0.5%)
async-load-publish                                                                     +216 B     (+0.6%)      +65 B     (+0.5%)
async-load-calypso-post-editor-media-modal                                             -210 B     (-0.0%)     -934 B     (-0.3%)
async-load-signup-steps-store-features                                                 +196 B     (+0.4%)     +250 B     (+1.8%)
async-load-signup-steps-intent                                                         +196 B     (+0.5%)     +229 B     (+1.8%)
async-load-calypso-layout-masterbar-checkout-tsx                                       -196 B     (-0.2%)     -491 B     (-1.2%)
async-load-calypso-layout-masterbar-checkout                                           -196 B     (-0.3%)     -547 B     (-2.2%)
async-load-calypso-jetpack-cloud-sections-sidebar-navigation-manage-selected-...       -196 B     (-0.2%)    -1023 B     (-3.5%)
async-load-masterbar-launchpad-navigator                                               +188 B     (+0.8%)     +742 B     (+9.3%)
async-load-calypso-my-sites-stats-pages-subscribers                                    +188 B     (+0.2%)     +740 B     (+1.7%)
async-load-purchase-modal-wrapper                                                      +134 B     (+0.0%)     +475 B     (+0.4%)
async-load-my-sites-checkout-purchase-modal-is-eligible-for-one-click-checkou...       +134 B     (+0.0%)     +469 B     (+0.4%)
async-load-signup-steps-design-picker                                                  +129 B     (+0.3%)      +47 B     (+0.3%)
async-load-signup-steps-woocommerce-install-confirm                                    -117 B     (-0.2%)     -226 B     (-1.2%)
async-load-calypso-state-lib-automated-transfer-middleware                             -117 B     (-0.4%)     -281 B     (-3.1%)
async-load-calypso-layout-guided-tours-component                                       -117 B     (-0.2%)     -306 B     (-2.4%)
async-load-calypso-blocks-support-article-dialog-dialog                                +117 B     (+0.1%)      +16 B     (+0.0%)
async-load-signup-steps-woocommerce-install-step-business-info                         -103 B     (-0.1%)      +21 B     (+0.1%)
async-load-signup-steps-domains                                                        -103 B     (-0.0%)       -8 B     (-0.0%)
async-load-signup-steps-theme-selection                                                 +96 B     (+0.0%)      -22 B     (-0.0%)
async-load-signup-steps-clone-point                                                     +96 B     (+0.1%)      +81 B     (+0.2%)
async-load-calypso-my-sites-stats-summary                                               +92 B     (+0.2%)      +16 B     (+0.1%)
async-load-calypso-my-sites-current-site-notice                                         +92 B     (+0.2%)      +18 B     (+0.1%)
async-load-calypso-blocks-jitm-templates-sidebar-banner                                 +92 B     (+0.2%)      +16 B     (+0.1%)
async-load-calypso-blocks-jitm-templates-notice                                         +92 B     (+0.2%)      +16 B     (+0.1%)
async-load-calypso-blocks-jitm-templates-default                                        +92 B     (+0.2%)      +17 B     (+0.1%)
async-load-calypso-my-sites-stats-stats-post-detail                                     -87 B     (-0.3%)      -38 B     (-0.4%)
async-load-calypso-my-sites-site-settings-seo-settings-form                             -87 B     (-0.0%)      -40 B     (-0.1%)
async-load-calypso-layout-masterbar-drafts-popover                                      +83 B     (+0.3%)      +10 B     (+0.1%)
async-load-automattic-help-center                                                       +82 B     (+0.0%)      -48 B     (-0.0%)
async-load-calypso-post-editor-editor-media-modal                                       +78 B     (+0.0%)     -254 B     (-0.1%)
async-load-signup-steps-woocommerce-install                                             -51 B     (-1.7%)      -20 B     (-1.8%)
async-load-calypso-layout-guided-tours                                                  -44 B     (-0.6%)      -24 B     (-1.1%)
async-load-signup-steps-p2-complete-profile                                             +40 B     (+0.0%)      +76 B     (+0.3%)
async-load-calypso-components-jetpack-portal-nav                                        +29 B     (+0.1%)       -8 B     (-0.1%)
async-load-store-app-store-stats                                                        -28 B     (-0.0%)      -24 B     (-0.0%)
async-load-store-app-store-stats-listview                                               +26 B     (+0.0%)       +8 B     (+0.0%)
async-load-signup-steps-woocommerce-install-step-store-address                          -25 B     (-0.0%)       -8 B     (-0.0%)
async-load-design-wordpress-components-gallery                                          -25 B     (-0.0%)      +26 B     (+0.0%)
async-load-calypso-reader-sidebar                                                       -25 B     (-0.0%)     -248 B     (-0.4%)
async-load-calypso-blocks-support-article-dialog                                        +21 B     (+0.7%)       +7 B     (+0.6%)
async-load-signup-steps-rewind-form-creds                                               -20 B     (-0.0%)      -68 B     (-0.3%)
async-load-signup-steps-clone-credentials                                               -20 B     (-0.0%)      -59 B     (-0.3%)
async-load-calypso-lib-account-settings-helper                                          +11 B     (+0.0%)      +50 B     (+0.1%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@sgomes sgomes requested a review from danluu May 17, 2024 16:48
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 17, 2024
@sgomes sgomes requested a review from a team May 17, 2024 16:48
@sgomes sgomes requested a review from alshakero May 17, 2024 16:56
@sgomes sgomes marked this pull request as ready for review May 17, 2024 16:56
Copy link
Contributor

@danluu danluu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I'm the right person to evaluate the correctness of this since I'm totally unfamiliar with the packages here, but following up on the performance discussion we had (and I'm going to repeat myself here and paste in some numbers from our 1 on 1 discussion for anyone else who wants to follow the discussion).

we have the following from the unused JS coverage in chrome dev tools going from /start to the design picker (for going through one flow — the true percentage of useful JS is better than this because users might do interactions that trigger functions that weren't used here, and these numbers should be uncompressed sizes, and also include some stuff like the React dev tools chrome extension, which isn’t really a WP thing, but is identical in both):

  • Prod: 3MB used of 8.7MB (5.7MB unused).
  • This version: 2.9MB used of 8.4MB (5.5MB unused).

I’m hoping (?) the drop in used JS is because I ran the Calypso Live version, which doesn’t seem to emit tracks events or emits fewer tracks is events and is maybe missing some other stuff, and not because setting "sideEffects": false actually caused a change.

In terms of measured performance, we had a 15s LCP at the start of the onboarding flow (at /start) on a Tecno Spark 8C with "Fast 3G" set in chrome dev tools. I tried measuring this a few more times and it’s moderately noisy and tends to land between 13.5s and 15s on the prod version. I tried this again with the Calypso Live version and saw basically the same numbers. It seems like this should be strictly better, so there should be an improvement here or somewhere else in the flow, but perhaps it’s small enough that we’d have to aggregate more runs to see the improvement.

I didn’t run through the whole flow because it’s fairly slow on a slow device and is resource intensive enough that it sometimes crashes, making it even slower, but for reference, the old version intent page had a 14s LCP and the design picker (business tab) had an 85s LCP (all of these “before” numbers are without #90741 but with #88786 and #88925).

@sgomes
Copy link
Contributor Author

sgomes commented May 20, 2024

I'm going to go ahead and merge this, as this is a no-code change, and smoke-testing seems to be safe.

@sgomes sgomes merged commit 33d1e85 into trunk May 20, 2024
21 checks passed
@sgomes sgomes deleted the update/tree-shake-stepper-declarative-flow-components branch May 20, 2024 09:49
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 20, 2024
@sgomes
Copy link
Contributor Author

sgomes commented May 20, 2024

Thank you for the review, @danluu! 👍

I’m hoping (?) the drop in used JS is because I ran the Calypso Live version, which doesn’t seem to emit tracks events or emits fewer tracks is events and is maybe missing some other stuff, and not because setting "sideEffects": false actually caused a change.

Yes, that sounds about right. I don't think it's easy to create a live branch for the branching point of a PR any more, otherwise we could double-check.

I tried this again with the Calypso Live version and saw basically the same numbers. It seems like this should be strictly better, so there should be an improvement here or somewhere else in the flow, but perhaps it’s small enough that we’d have to aggregate more runs to see the improvement.

Right, this is one of those "all other things being equal, fewer bytes is better" changes.

@arthur791004
Copy link
Contributor

arthur791004 commented May 21, 2024

Revert it as some styles are not loaded. See p1716262266425289-slack-C02FMH4G8.

arthur791004 added a commit that referenced this pull request May 21, 2024
…y" (#90917)

* Revert "Ensure stepper decl. flow components tree-shake (#90851)"

This reverts commit 33d1e85.

* Fix Run eslint
@sgomes
Copy link
Contributor Author

sgomes commented May 21, 2024

Sorry for the breakage, and thank you for handling the revert, @arthur791004 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants