Skip to content

MostViewedFooter as an island - #3942

Merged
oliverlloyd merged 8 commits into
mainfrom
oliver/mostviewedfooter-island
Feb 10, 2022
Merged

oliverlloyd merged 8 commits into
mainfrom
oliver/mostviewedfooter-island

Conversation

@oliverlloyd

@oliverlloyd oliverlloyd commented Feb 8, 2022 •

Copy link
Copy Markdown
Contributor

What does this change?

Moves MostViewedFooter into an island

Why?

Less javascript on initial page load

Why MostViewedFooterLayout?

I added this extra component so that we can have something to wrap with WithABProvider . The ABProvider component must wrap the component that wants to use useAB which in this case was happening at the root (in MostViewedFooter) so in this case we needed an extra layer of composition

Do we now need to manually insert WithABProvider?

This code introduces a pattern where we're asking developers to wrap their client side code with WithABProvider where needed. But maybe we can incorporate this into the Islands abstraction itself? See this discussion

@oliverlloyd
oliverlloyd requested review from a team, JamieB-gu and marsavar as code owners February 8, 2022 14:41
@oliverlloyd
oliverlloyd marked this pull request as draft February 8, 2022 14:44
@github-actions github-actions Bot added the dotcom label Feb 8, 2022
@github-actions

github-actions Bot commented Feb 8, 2022 •

Copy link
Copy Markdown

Size Change: -85.4 kB (-6%) ✅

Total Size: 1.24 MB

Filename Size Change
dotcom-rendering/dist/1983.js 0 B -13.8 kB (removed) 🏆
dotcom-rendering/dist/1983.legacy.js 0 B -14.4 kB (removed) 🏆
dotcom-rendering/dist/3213.js 13 kB -9 B (0%)
dotcom-rendering/dist/3213.legacy.js 13.2 kB +6 B (0%)
dotcom-rendering/dist/3777.legacy.js 0 B -6.41 kB (removed) 🏆
dotcom-rendering/dist/4999.js 17.9 kB -26 B (0%)
dotcom-rendering/dist/4999.legacy.js 18.5 kB -19 B (0%)
dotcom-rendering/dist/5373.legacy.js 0 B -3.58 kB (removed) 🏆
dotcom-rendering/dist/602.js 0 B -8.66 kB (removed) 🏆
dotcom-rendering/dist/602.legacy.js 0 B -8.92 kB (removed) 🏆
dotcom-rendering/dist/6916.js 0 B -8.25 kB (removed) 🏆
dotcom-rendering/dist/6916.legacy.js 0 B -8.71 kB (removed) 🏆
dotcom-rendering/dist/8330.js 0 B -3.21 kB (removed) 🏆
dotcom-rendering/dist/8497.js 0 B -4.01 kB (removed) 🏆
dotcom-rendering/dist/cmp.js 7.51 kB +1 B (0%)
dotcom-rendering/dist/frontend.server.js 314 kB +12.1 kB (+4%)
dotcom-rendering/dist/initDiscussion.js 7.61 kB +129 B (+2%)
dotcom-rendering/dist/initDiscussion.legacy.js 7.86 kB +122 B (+2%)
dotcom-rendering/dist/islands.js 7.77 kB +137 B (+2%)
dotcom-rendering/dist/islands.legacy.js 8.49 kB +109 B (+1%)
dotcom-rendering/dist/MostViewedFooterData.js 0 B -6.25 kB (removed) 🏆
dotcom-rendering/dist/MostViewedFooterData.legacy.js 0 B -6.34 kB (removed) 🏆
dotcom-rendering/dist/react.js 84.1 kB -2.61 kB (-3%)
dotcom-rendering/dist/react.legacy.js 90.7 kB -2.75 kB (-3%)
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/1214.js 2.14 kB
dotcom-rendering/dist/1214.legacy.js 2.19 kB
dotcom-rendering/dist/1376.js 3.63 kB
dotcom-rendering/dist/1376.legacy.js 3.82 kB
dotcom-rendering/dist/1672.js 3.72 kB
dotcom-rendering/dist/1924.js 4.57 kB
dotcom-rendering/dist/1924.legacy.js 4.69 kB
dotcom-rendering/dist/262.js 7.25 kB
dotcom-rendering/dist/2666.js 30.6 kB
dotcom-rendering/dist/2879.js 6.92 kB
dotcom-rendering/dist/2879.legacy.js 7.14 kB
dotcom-rendering/dist/3203.js 8.29 kB
dotcom-rendering/dist/3203.legacy.js 8.76 kB
dotcom-rendering/dist/3215.js 4.88 kB
dotcom-rendering/dist/3215.legacy.js 5.05 kB
dotcom-rendering/dist/3321.legacy.js 28.5 kB
dotcom-rendering/dist/3397.js 240 B
dotcom-rendering/dist/3397.legacy.js 251 B
dotcom-rendering/dist/343.js 3.73 kB
dotcom-rendering/dist/343.legacy.js 3.91 kB
dotcom-rendering/dist/3639.js 5.24 kB
dotcom-rendering/dist/3639.legacy.js 5.42 kB
dotcom-rendering/dist/3729.js 1.28 kB
dotcom-rendering/dist/3729.legacy.js 1.36 kB
dotcom-rendering/dist/4415.legacy.js 3.56 kB
dotcom-rendering/dist/45.legacy.js 3.55 kB
dotcom-rendering/dist/4576.js 235 B
dotcom-rendering/dist/4576.legacy.js 247 B
dotcom-rendering/dist/4850.js 235 B
dotcom-rendering/dist/4850.legacy.js 246 B
dotcom-rendering/dist/5217.js 233 B
dotcom-rendering/dist/5217.legacy.js 245 B
dotcom-rendering/dist/53.js 4.11 kB
dotcom-rendering/dist/53.legacy.js 4.12 kB
dotcom-rendering/dist/5585.js 5.26 kB
dotcom-rendering/dist/5585.legacy.js 5.41 kB
dotcom-rendering/dist/6046.js 2.94 kB
dotcom-rendering/dist/6046.legacy.js 3.04 kB
dotcom-rendering/dist/6146.legacy.js 5.85 kB
dotcom-rendering/dist/6348.js 4.58 kB
dotcom-rendering/dist/6348.legacy.js 4.75 kB
dotcom-rendering/dist/6372.legacy.js 3.89 kB
dotcom-rendering/dist/6400.js 21.5 kB
dotcom-rendering/dist/6400.legacy.js 21.5 kB
dotcom-rendering/dist/6684.js 241 B
dotcom-rendering/dist/6684.legacy.js 252 B
dotcom-rendering/dist/6698.js 3.15 kB
dotcom-rendering/dist/6698.legacy.js 3.23 kB
dotcom-rendering/dist/6965.js 2.64 kB
dotcom-rendering/dist/6965.legacy.js 2.71 kB
dotcom-rendering/dist/7051.js 7.22 kB
dotcom-rendering/dist/7051.legacy.js 7.37 kB
dotcom-rendering/dist/7317.js 3.4 kB
dotcom-rendering/dist/7489.js 3.4 kB
dotcom-rendering/dist/7642.legacy.js 9.98 kB
dotcom-rendering/dist/7754.legacy.js 3.56 kB
dotcom-rendering/dist/7800.js 11 kB
dotcom-rendering/dist/8080.js 3.52 kB
dotcom-rendering/dist/8080.legacy.js 3.7 kB
dotcom-rendering/dist/8129.legacy.js 11.5 kB
dotcom-rendering/dist/8294.js 232 B
dotcom-rendering/dist/8294.legacy.js 244 B
dotcom-rendering/dist/831.js 4.14 kB
dotcom-rendering/dist/831.legacy.js 4.45 kB
dotcom-rendering/dist/8748.js 232 B
dotcom-rendering/dist/8748.legacy.js 243 B
dotcom-rendering/dist/9212.js 3.4 kB
dotcom-rendering/dist/9641.js 5.23 kB
dotcom-rendering/dist/9641.legacy.js 5.4 kB
dotcom-rendering/dist/9682.js 5.4 kB
dotcom-rendering/dist/9776.js 5.15 kB
dotcom-rendering/dist/9776.legacy.js 5.33 kB
dotcom-rendering/dist/9884.js 17 kB
dotcom-rendering/dist/9884.legacy.js 17.3 kB
dotcom-rendering/dist/9970.js 14.4 kB
dotcom-rendering/dist/9970.legacy.js 14.6 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.14 kB
dotcom-rendering/dist/bootCmp.js 7.39 kB
dotcom-rendering/dist/bootCmp.legacy.js 10.9 kB
dotcom-rendering/dist/braze-web-sdk-core.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.js 36.1 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.33 kB
dotcom-rendering/dist/dynamicImport.js 3 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.29 kB
dotcom-rendering/dist/embedIframe.js 1.88 kB
dotcom-rendering/dist/embedIframe.legacy.js 2.14 kB
dotcom-rendering/dist/ga.js 3.88 kB
dotcom-rendering/dist/ga.legacy.js 4.14 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 10.6 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 10.6 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.61 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.62 kB
dotcom-rendering/dist/InteractiveBlockComponent.js 3.03 kB
dotcom-rendering/dist/InteractiveBlockComponent.legacy.js 3.18 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 2.03 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.29 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/readerRevenueDevUtils.js 892 B
dotcom-rendering/dist/readerRevenueDevUtils.legacy.js 952 B
dotcom-rendering/dist/relativeTime.js 2.41 kB
dotcom-rendering/dist/relativeTime.legacy.js 2.68 kB
dotcom-rendering/dist/sentry.js 677 B
dotcom-rendering/dist/sentry.legacy.js 689 B
dotcom-rendering/dist/sentryLoader.js 4.75 kB
dotcom-rendering/dist/sentryLoader.legacy.js 7.71 kB
dotcom-rendering/dist/shimport.js 2.75 kB
dotcom-rendering/dist/shimport.legacy.js 2.76 kB
dotcom-rendering/dist/SignInGateMain.js 1.84 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.88 kB
dotcom-rendering/dist/YoutubeBlockComponent.js 2.9 kB
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 3.03 kB

compressed-size-action

Comment on lines +54 to +56
switches={{}}
pageIsSensitive={false}
isDev={false}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I''m passing these in to be used by WithABProvider


import { useApi as useApi_ } from '../../../lib/useApi';
import { decidePalette } from '../../../lib/decidePalette';
import { useApi as useApi_ } from '../lib/useApi';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's a bunch of these import changes which are merge conflict hangovers

@oliverlloyd
oliverlloyd marked this pull request as ready for review February 9, 2022 15:12

@jamesgorrie jamesgorrie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a question that I think will help me with the review.

format={format}
ajaxUrl={ajaxUrl}
/>
</WithABProvider>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this reason we need WithABProvider here because this is being loaded in dynamically and so doesn't inherit the BootReact WithABProvider?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly. We're no longer in the same context (the same stack) as BootReact so we need to set our own AB provider

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a pattern we will continue to see then and could we look at adding this to the islands code? e.g. All islands have the same as the Boot context?

(another PR / discussion maybe)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I considered this approach (I'll update the PR description to include this) but it turned out to make the inclusion of this AB code dynamic (only when needed/wanted) I would have needed to change the code both in the Island server side component and also the doHydration client side code. It felt like adding more coupling to this for what is a secondary concern wasn't the right thing to do.

The alternative to the dynamic coupling is to just always set it. Which is an option. I guess the discussion is around the trade off between optimisation and dev ex. I think this is a worthwhile discussion to have so I'll raise it 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussion: #3955

Comment thread dotcom-rendering/src/web/components/SecondTierItem.tsx
Comment thread dotcom-rendering/src/web/components/MostViewedFooterLayout.tsx
@oliverlloyd
oliverlloyd merged commit 1f1d635 into main Feb 10, 2022
@oliverlloyd
oliverlloyd deleted the oliver/mostviewedfooter-island branch February 10, 2022 12:48
@mxdvl

mxdvl commented Mar 1, 2022

Copy link
Copy Markdown
Contributor

🏝️ #3629

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants