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

[no-Jira] Reduce initial client bundle size #895

Merged
merged 17 commits into from
Apr 29, 2024
Merged

[no-Jira] Reduce initial client bundle size #895

merged 17 commits into from
Apr 29, 2024

Conversation

canac
Copy link
Contributor

@canac canac commented Mar 21, 2024

Description

Main improvements:

  • Decrease bundle sizes by lazy-loading modals and panels that aren't visible until being clicked.
  • Decrease bundle sizes by optimizing imports, notably lodash.
  • Combine redundant Contacts queries in the contacts list.

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-895.d3dytjb8adxkk5.amplifyapp.com

@canac canac force-pushed the lazy-components branch from 43e76af to 69441a2 Compare March 25, 2024 17:09
Copy link
Contributor

github-actions bot commented Mar 25, 2024

Bundle Sizes

Compared against e39bab0

Route Size (gzipped) Diff
/ 79.88 KB +2.33 KB
/404 80.45 KB +2.33 KB
/500 80.41 KB +2.33 KB
/_app 368.76 KB -208.25 KB
/_error 79.68 KB +2.33 KB
/accountLists 119.8 KB +36.51 KB
/accountLists/[accountListId] 271.51 KB +40.84 KB
/accountLists/[accountListId]/coaching 84.13 KB +3.18 KB
/accountLists/[accountListId]/coaching/[coachingId] 245.75 KB +45.86 KB
/accountLists/[accountListId]/contacts/[[...contactId]] 103.93 KB -236.62 KB
/accountLists/[accountListId]/contacts/flows/setup 145.77 KB -10.6 KB
/accountLists/[accountListId]/reports/coaching 245.76 KB +45.86 KB
/accountLists/[accountListId]/reports/designationAccounts 241.05 KB +10.4 KB
/accountLists/[accountListId]/reports/donations/[[...contactId]] 343.9 KB -51.71 KB
/accountLists/[accountListId]/reports/expectedMonthlyTotal 107.63 KB -21.25 KB
/accountLists/[accountListId]/reports/partnerCurrency/[[...contactId]] 133.5 KB -182.29 KB
/accountLists/[accountListId]/reports/partnerGivingAnalysis/[[...contactId]] 130.91 KB -181.46 KB
/accountLists/[accountListId]/reports/responsibilityCenters 241.98 KB +10.49 KB
/accountLists/[accountListId]/reports/salaryCurrency/[[...contactId]] 133.49 KB -182.3 KB
/accountLists/[accountListId]/settings/admin 134.51 KB +2.34 KB
/accountLists/[accountListId]/settings/integrations 155.02 KB +4.74 KB
/accountLists/[accountListId]/settings/manageAccounts 142.86 KB +5.16 KB
/accountLists/[accountListId]/settings/manageCoaches 138.65 KB +3.33 KB
/accountLists/[accountListId]/settings/notifications 135.16 KB +4.49 KB
/accountLists/[accountListId]/settings/organizations 136.35 KB +2.44 KB
/accountLists/[accountListId]/settings/organizations/accountLists 132.35 KB -20.79 KB
/accountLists/[accountListId]/settings/organizations/contacts 131.18 KB -20.85 KB
/accountLists/[accountListId]/settings/preferences 210.27 KB +50.78 KB
/accountLists/[accountListId]/tasks/[[...contactId]] 136.4 KB -173.77 KB
/accountLists/[accountListId]/tools 114.44 KB +35.39 KB
/accountLists/[accountListId]/tools/appeals 159.41 KB +74.72 KB
/accountLists/[accountListId]/tools/appeals/[appealId] 181.04 KB +23.18 KB
/accountLists/[accountListId]/tools/fixCommitmentInfo 90.9 KB +3.51 KB
/accountLists/[accountListId]/tools/fixEmailAddresses 89.82 KB +2.91 KB
/accountLists/[accountListId]/tools/fixMailingAddresses 92.67 KB +3.67 KB
/accountLists/[accountListId]/tools/fixPhoneNumbers 90.12 KB +2.9 KB
/accountLists/[accountListId]/tools/fixSendNewsletter 88.66 KB +2.35 KB
/accountLists/[accountListId]/tools/mergeContacts 86.93 KB +2.72 KB
/accountLists/[accountListId]/tools/mergePeople 86.5 KB +2.33 KB
/login 119.66 KB +36.1 KB
/logout 80.27 KB +2.33 KB
Dynamic import Size (gzipped)
../src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactDetailsMoreActions/DynamicMoreActionHideContactModal.tsx -> ./MoreActionHideContactModal 598 B
../src/components/Contacts/ContactDetails/ContactDetailsHeader/DeleteContactModal/DynamicDeleteContactModal.tsx -> ./DeleteContactModal 651 B
../src/components/Contacts/ContactDetails/ContactDetailsTab/DynamicContactDetailsTab.tsx -> ./ContactDetailsTab 62.53 KB
../src/components/Contacts/ContactDetails/ContactDonationsTab/DynamicContactDonationsTab.tsx -> ./ContactDonationsTab 101.87 KB
../src/components/Contacts/ContactDetails/ContactNotesTab/DynamicContactNotesTab.tsx -> ./ContactNotesTab 2.25 KB
../src/components/Contacts/ContactDetails/ContactReferralTab/DynamicContactReferralTab.tsx -> ./ContactReferralTab 4.42 KB
../src/components/Contacts/ContactFlow/DynamicContactFlow.tsx -> ./ContactFlow 40.57 KB
../src/components/Contacts/ContactsList/DynamicContactsList.tsx -> ./ContactsList 28.74 KB
../src/components/Contacts/ContactsMap/DynamicContactsMap.tsx -> ./ContactsMap 30.65 KB
../src/components/Contacts/ContactsMap/DynamicContactsMapPanel.tsx -> ./ContactsMapPanel 6.21 KB
../src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel.tsx -> ./ContactsRightPanel 135.5 KB
../src/components/Contacts/MassActions/AddTags/DynamicMassActionsAddTagsModal.tsx -> ./MassActionsAddTagsModal 39.17 KB
../src/components/Contacts/MassActions/AddToAppeal/DynamicMassActionsAddToAppealModal.tsx -> ./MassActionsAddToAppealModal 38.48 KB
../src/components/Contacts/MassActions/AddToAppeal/DynamicMassActionsCreateAppealModal.tsx -> ./MassActionsCreateAppealModal 27 KB
../src/components/Contacts/MassActions/EditFields/DynamicMassActionsEditFieldsModal.tsx -> ./MassActionsEditFieldsModal 82.71 KB
../src/components/Contacts/MassActions/Exports/DynamicExportsModal.tsx -> ./ExportsModal 2.5 KB
../src/components/Contacts/MassActions/Exports/Emails/DynamicMassActionsExportEmailsModal.tsx -> ./MassActionsExportEmailsModal 2.95 KB
../src/components/Contacts/MassActions/Exports/MailMergedLabelModal/DynamicMailMergedLabelModal.tsx -> ./MailMergedLabelModal 28.74 KB
../src/components/Contacts/MassActions/Merge/DynamicMassActionsMergeModal.tsx -> ./MassActionsMergeModal 4.1 KB
../src/components/Contacts/MassActions/RemoveTags/DynamicMassActionsRemoveTagsModal.tsx -> ./MassActionsRemoveTagsModal 27.8 KB
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/ExportEmail/DynamicExportEmail.tsx -> ./ExportEmail 2.31 KB
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/ExportPhysical/DynamicExportPhysical.tsx -> ./ExportPhysical 3.53 KB
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/DynamicLogNewsletter.tsx -> ./LogNewsletter 90.68 KB
../src/components/Dashboard/ThisWeek/WeeklyActivity/WeeklyReportModal/DynamicWeeklyReportModal.tsx -> ./WeeklyReportModal 34.55 KB
../src/components/EditDonationModal/DynamicEditDonationModal.tsx -> ./EditDonationModal 73.43 KB
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/AddDonation/DynamicAddDonation.tsx -> ./AddDonation 86.22 KB
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/DynamicCreateContact.tsx -> ./CreateContact 28.45 KB
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/DynamicCreateMultipleContacts.tsx -> ./CreateMultipleContacts 76.41 KB
../src/components/Layouts/Primary/TopBar/Items/SearchMenu/DynamicSearchDialog.tsx -> ./SearchDialog 16.17 KB
../src/components/Shared/Filters/DynamicFilterPanel.tsx -> ./FilterPanel 100.38 KB
../src/components/Shared/HideContactsModal/DynamicHideContactsModal.tsx -> ./HideContactsModal 1.34 KB
../src/components/Task/MassActions/AddTags/DynamicMassActionsTasksAddTagsModal.tsx -> ./MassActionsTasksAddTagsModal 40.13 KB
../src/components/Task/MassActions/ConfirmationModal/DynamicMassActionsTasksConfirmationModal.tsx -> ./MassActionsTasksConfirmationModal 1.3 KB
../src/components/Task/MassActions/EditTasks/DynamicMassActionsEditTasksModal.tsx -> ./MassActionsEditTasksModal 98.28 KB
../src/components/Task/MassActions/RemoveTags/DynamicMassActionsTasksRemoveTagsModal.tsx -> ./MassActionsTasksRemoveTagsModal 28.63 KB
../src/components/Task/Modal/Comments/DynamicTaskModalCommentsList.tsx -> ./TaskModalCommentsList 74.22 KB
../src/components/Task/Modal/Form/Complete/DynamicTaskModalCompleteForm.tsx -> ./TaskModalCompleteForm 98.35 KB
../src/components/Task/Modal/Form/DynamicTaskModalForm.tsx -> ./TaskModalForm 107.16 KB
../src/components/Task/Modal/Form/LogForm/DynamicTaskModalLogForm.tsx -> ./TaskModalLogForm 141.13 KB

@canac canac force-pushed the lazy-components branch 7 times, most recently from a82a526 to ff66c4b Compare April 2, 2024 21:27
@canac canac requested a review from dr-bizz April 2, 2024 21:29
Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

I've reviewed all your commits and files up to the last WIP commit.
I have left some comments, but it looks truly amazing! Dynamic imports could save a lot of load time, plus the other benefits you've added here.

I did find that in the last few comments, mostly Lazy load contacts views there were lots of imports with ../../ when you don't need to add them and call straight from src/ or pages/.

Comment on lines +133 to +164
{contactId && accountListId && (
<DynamicContactReferralTab
accountListId={accountListId}
contactId={contactId}
onContactSelected={setContactFocus}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here is a good place to add a skeleton. Not saying you should do this, but I should in my PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The JS for the tabs load in about 100ms. I don't think the skeleton will be visible long enough to warrant spending the time to make one for the lazy-loaded component. But you can create skeletons that will be visible while waiting for the GraphQL data to load because those can take longer.

@@ -143,7 +143,7 @@ export const SidePanelsLayout: FC<SidePanelsLayoutProps> = ({
transform: rightOpen ? 'none' : 'translate(100%)',
}}
>
{rightPanel}
{rightOpen && rightPanel}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you also want to add LeftOpen to the leftPanel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I did already

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a .tsx file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's .ts right now because it contains no JSX. Let me know if you think I should change it to .tsx. It probably makes more sense for me to rename src/components/Settings/notifications/StyledComponents.tsx to StyledComponents.ts for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be named StylesComponents as when we add the Tools functionality, we will add shared components to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The exported component is technically a regular component, not a styled component, so I feel that it would be misleading to rename this file to StyledComponents.tsx. But we can certainly refactor and combine whatever makes sense when we implement the tools.

@canac canac force-pushed the lazy-components branch from 3c8ae49 to 3280442 Compare April 5, 2024 15:21
@canac
Copy link
Contributor Author

canac commented Apr 5, 2024

Dynamic imports could save a lot of load time, plus the other benefits you've added here.

Thanks! It should be even better now that I implemented preloading on hover. Unless they're quick clickers or have an especially slow network, hopefully most of the time our users won't even see the lazy loading spinner.

@canac canac requested a review from dr-bizz April 5, 2024 16:53
Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

First off, Thank you for wortking on this. This is truly amazing what you've been able to do.

I have reviewed all 463 files. due to the amount of files, I haven't been able to do a deep dive into each file, but more of an overview. With that we need to make sure to do a lot more testing on the PR preview. I will continue testing this week and next.

Going forward, we need to limit the amount of files in a PR, I don't know the number yet, but this was too much and could have been split into multiple PRs.

src/components/Tool/Appeal/AppealDrawer/AppealDrawer.tsx Outdated Show resolved Hide resolved
@canac
Copy link
Contributor Author

canac commented Apr 11, 2024

@dr-bizz Thanks for the review. Sorry that it was such a big PR. I should have put commit that adjusts import paths in a separate PR instead of tacking it onto this one.

Last week, I went through every changed file and made sure that hovering preloads the right chunk and that the buttons open the right modal. I feel very confident about my direct changes, but we can keep testing to try to find unintentional indirect changes. Did you have specific things in mind that you'd like to make sure gets tested?

@canac canac mentioned this pull request Apr 12, 2024
3 tasks
Copy link
Contributor

github-actions bot commented Apr 19, 2024

Bundle sizes [mpdx-react]

Compared against d35fe11

Route Size (gzipped) Diff
/ 79.89 KB +2.33 KB
/404 80.46 KB +2.33 KB
/500 80.42 KB +2.33 KB
/_app 369.17 KB -208.21 KB
/_error 79.68 KB +2.33 KB
/accountLists 119.81 KB +36.52 KB
/accountLists/[accountListId] 271.53 KB +40.84 KB
/accountLists/[accountListId]/coaching 84.13 KB +3.18 KB
/accountLists/[accountListId]/coaching/[coachingId] 245.77 KB +45.86 KB
/accountLists/[accountListId]/contacts/[[...contactId]] 103.94 KB -236.59 KB
/accountLists/[accountListId]/contacts/flows/setup 145.77 KB -10.6 KB
/accountLists/[accountListId]/reports/coaching 245.77 KB +45.86 KB
/accountLists/[accountListId]/reports/designationAccounts 241.48 KB +8.24 KB
/accountLists/[accountListId]/reports/donations/[[...contactId]] 344.19 KB -51.65 KB
/accountLists/[accountListId]/reports/expectedMonthlyTotal 107.92 KB -21.27 KB
/accountLists/[accountListId]/reports/partnerCurrency/[[...contactId]] 133.88 KB -183.09 KB
/accountLists/[accountListId]/reports/partnerGivingAnalysis/[[...contactId]] 131.48 KB -184.56 KB
/accountLists/[accountListId]/reports/responsibilityCenters 242.41 KB +8.34 KB
/accountLists/[accountListId]/reports/salaryCurrency/[[...contactId]] 133.88 KB -183.09 KB
/accountLists/[accountListId]/settings/admin 134.85 KB +2.18 KB
/accountLists/[accountListId]/settings/integrations 155.45 KB +4.58 KB
/accountLists/[accountListId]/settings/manageAccounts 143.2 KB +5.04 KB
/accountLists/[accountListId]/settings/manageCoaches 138.99 KB +3.2 KB
/accountLists/[accountListId]/settings/notifications 135.51 KB +4.36 KB
/accountLists/[accountListId]/settings/organizations 136.69 KB +2.28 KB
/accountLists/[accountListId]/settings/organizations/accountLists 132.7 KB -20.91 KB
/accountLists/[accountListId]/settings/organizations/contacts 131.53 KB -20.97 KB
/accountLists/[accountListId]/settings/preferences 210.84 KB +50.58 KB
/accountLists/[accountListId]/tasks/[[...contactId]] 136.44 KB -173.72 KB
/accountLists/[accountListId]/tools 114.45 KB +35.39 KB
/accountLists/[accountListId]/tools/appeals 159.42 KB +74.72 KB
/accountLists/[accountListId]/tools/appeals/[appealId] 181.06 KB +23.18 KB
/accountLists/[accountListId]/tools/fixCommitmentInfo 90.91 KB +3.51 KB
/accountLists/[accountListId]/tools/fixEmailAddresses 89.82 KB +2.92 KB
/accountLists/[accountListId]/tools/fixMailingAddresses 92.68 KB +3.67 KB
/accountLists/[accountListId]/tools/fixPhoneNumbers 90.12 KB +2.9 KB
/accountLists/[accountListId]/tools/fixSendNewsletter 88.67 KB +2.35 KB
/accountLists/[accountListId]/tools/mergeContacts 86.94 KB +2.72 KB
/accountLists/[accountListId]/tools/mergePeople 86.5 KB +2.33 KB
/login 119.67 KB +36.1 KB
/logout 80.28 KB +2.33 KB
Dynamic import Size (gzipped) Diff
../src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactDetailsMoreActions/DynamicMoreActionHideContactModal.tsx -> ./MoreActionHideContactModal 598 B added
../src/components/Contacts/ContactDetails/ContactDetailsHeader/DeleteContactModal/DynamicDeleteContactModal.tsx -> ./DeleteContactModal 651 B added
../src/components/Contacts/ContactDetails/ContactDetailsTab/DynamicContactDetailsTab.tsx -> ./ContactDetailsTab 62.53 KB added
../src/components/Contacts/ContactDetails/ContactDonationsTab/DynamicContactDonationsTab.tsx -> ./ContactDonationsTab 101.87 KB added
../src/components/Contacts/ContactDetails/ContactNotesTab/DynamicContactNotesTab.tsx -> ./ContactNotesTab 2.25 KB added
../src/components/Contacts/ContactDetails/ContactReferralTab/DynamicContactReferralTab.tsx -> ./ContactReferralTab 4.42 KB added
../src/components/Contacts/ContactFlow/DynamicContactFlow.tsx -> ./ContactFlow 40.58 KB added
../src/components/Contacts/ContactsList/DynamicContactsList.tsx -> ./ContactsList 28.75 KB added
../src/components/Contacts/ContactsMap/DynamicContactsMap.tsx -> ./ContactsMap 30.65 KB added
../src/components/Contacts/ContactsMap/DynamicContactsMapPanel.tsx -> ./ContactsMapPanel 6.21 KB added
../src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel.tsx -> ./ContactsRightPanel 135.51 KB added
../src/components/Contacts/MassActions/AddTags/DynamicMassActionsAddTagsModal.tsx -> ./MassActionsAddTagsModal 39.17 KB added
../src/components/Contacts/MassActions/AddToAppeal/DynamicMassActionsAddToAppealModal.tsx -> ./MassActionsAddToAppealModal 38.48 KB added
../src/components/Contacts/MassActions/AddToAppeal/DynamicMassActionsCreateAppealModal.tsx -> ./MassActionsCreateAppealModal 27 KB added
../src/components/Contacts/MassActions/EditFields/DynamicMassActionsEditFieldsModal.tsx -> ./MassActionsEditFieldsModal 82.72 KB added
../src/components/Contacts/MassActions/Exports/DynamicExportsModal.tsx -> ./ExportsModal 2.5 KB added
../src/components/Contacts/MassActions/Exports/Emails/DynamicMassActionsExportEmailsModal.tsx -> ./MassActionsExportEmailsModal 2.95 KB added
../src/components/Contacts/MassActions/Exports/MailMergedLabelModal/DynamicMailMergedLabelModal.tsx -> ./MailMergedLabelModal 28.74 KB added
../src/components/Contacts/MassActions/Merge/DynamicMassActionsMergeModal.tsx -> ./MassActionsMergeModal 4.1 KB added
../src/components/Contacts/MassActions/RemoveTags/DynamicMassActionsRemoveTagsModal.tsx -> ./MassActionsRemoveTagsModal 27.8 KB added
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/ExportEmail/DynamicExportEmail.tsx -> ./ExportEmail 2.31 KB added
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/ExportPhysical/DynamicExportPhysical.tsx -> ./ExportPhysical 3.53 KB added
../src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/DynamicLogNewsletter.tsx -> ./LogNewsletter 90.69 KB added
../src/components/Dashboard/ThisWeek/WeeklyActivity/WeeklyReportModal/DynamicWeeklyReportModal.tsx -> ./WeeklyReportModal 34.55 KB added
../src/components/EditDonationModal/DynamicEditDonationModal.tsx -> ./EditDonationModal 73.43 KB added
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/AddDonation/DynamicAddDonation.tsx -> ./AddDonation 86.23 KB added
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/DynamicCreateContact.tsx -> ./CreateContact 28.44 KB added
../src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/DynamicCreateMultipleContacts.tsx -> ./CreateMultipleContacts 76.41 KB added
../src/components/Layouts/Primary/TopBar/Items/SearchMenu/DynamicSearchDialog.tsx -> ./SearchDialog 16.17 KB added
../src/components/Shared/Filters/DynamicFilterPanel.tsx -> ./FilterPanel 100.41 KB added
../src/components/Shared/HideContactsModal/DynamicHideContactsModal.tsx -> ./HideContactsModal 1.34 KB added
../src/components/Task/MassActions/AddTags/DynamicMassActionsTasksAddTagsModal.tsx -> ./MassActionsTasksAddTagsModal 40.13 KB added
../src/components/Task/MassActions/ConfirmationModal/DynamicMassActionsTasksConfirmationModal.tsx -> ./MassActionsTasksConfirmationModal 1.3 KB added
../src/components/Task/MassActions/EditTasks/DynamicMassActionsEditTasksModal.tsx -> ./MassActionsEditTasksModal 98.29 KB added
../src/components/Task/MassActions/RemoveTags/DynamicMassActionsTasksRemoveTagsModal.tsx -> ./MassActionsTasksRemoveTagsModal 28.63 KB added
../src/components/Task/Modal/Comments/DynamicTaskModalCommentsList.tsx -> ./TaskModalCommentsList 74.16 KB added
../src/components/Task/Modal/Form/Complete/DynamicTaskModalCompleteForm.tsx -> ./TaskModalCompleteForm 98.35 KB added
../src/components/Task/Modal/Form/DynamicTaskModalForm.tsx -> ./TaskModalForm 107.17 KB added
../src/components/Task/Modal/Form/LogForm/DynamicTaskModalLogForm.tsx -> ./TaskModalLogForm 141.14 KB added
../src/components/common/Modal/DynamicModal.tsx -> ./Modal no change removed

onClick={() => setAddDonationOpen(true)}
>
{t('Add New Donation')}
</Button>
)}
</Box>

<DynamicModal
<Modal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dr-bizz The AddDonation component is the heaviest and the more important one to lazy load. And like we discussed earlier, lazy loading Modal here does nothing because it's used directly in so many places that it's already part of the bundle. I also think it's a better UX to lazy load the modal body but not the title, so that the user can at least see the title of the modal while the body loads.

Anyway, this commit reverts the Modal lazy loading you added since that change doesn't do anything, but please push back if you disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, Lazy loading the body is a good way to go for now.

In another PR, we should make the Dynamic Modal component have a property of title so that when it renders, it shows the user the Modal title while loading the Component. There might be some layout shift.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In another PR, we should make the Dynamic Modal component have a property of title so that when it renders, it shows the user the Modal title while loading the Component. There might be some layout shift.

We can definitely look into that. Although it seems like we'd just be reimplementing Modal at that point. And Modal isn't a very heavy component. Removing it from the initial bundle only shaves off 1-2kb when I tried it. Also we'll create a network request waterfall if we lazy load Modal and its content.

@canac canac added the On Staging Will be merged to the staging branch by Github Actions label Apr 19, 2024
@canac canac requested a review from dr-bizz April 22, 2024 19:36
@canac
Copy link
Contributor Author

canac commented Apr 22, 2024

@dr-bizz I tested everything again in staging, and it's all working correctly as far as I can tell.

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

@canac I've tested this on staging and it looks awesome! Pages and components are loading super fast. This work will greatly increase productivity for users.

When we roll this live, we need to watch for a number of days, as it's such a large change and things could be reported a few days after going live. With that, it might be best to wait to Monday to merge into production, so you can be around if it breaks.

@canac canac force-pushed the lazy-components branch 2 times, most recently from f739ff0 to da17fb4 Compare April 29, 2024 14:05
@canac canac merged commit c427b08 into main Apr 29, 2024
31 of 33 checks passed
@canac canac deleted the lazy-components branch April 29, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On Staging Will be merged to the staging branch by Github Actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants