Skip to content

Atoms as islands - #3912

Merged
oliverlloyd merged 4 commits into
mainfrom
oliver/atoms-as-islands
Feb 2, 2022
Merged

oliverlloyd merged 4 commits into
mainfrom
oliver/atoms-as-islands

Conversation

@oliverlloyd

Copy link
Copy Markdown
Contributor

What does this change?

Here we're moving a bunch of atoms into Islands. Specifically,

	QandaAtom
	GuideAtom
	ProfileAtom
	TimelineAtom
	ChartAtom
	PersonalityQuizAtom
	KnowledgeQuizAtom

We're also add version 22.2.0 of @guardian/atoms-rendering which allows us to remove the tracking handlers

Why?

Islands are cool.

Why are we removing the tracking handlers? Because adding these on the server and then trying to hydrate them was non intuitive and added complexity. By adding a default to the atom itself we can simply not include the handler and use the fallback instead.

What are these wrapper components?

For code that's imported from an external lib it's not possible for our Island abstraction to dynamcally import it because we currently require island components to exist in /component. To get around this we use a simple wrapper, as shown here.

@oliverlloyd
oliverlloyd requested review from a team, JamieB-gu and marsavar as code owners February 2, 2022 14:35
@github-actions github-actions Bot added the dotcom label Feb 2, 2022
Comment on lines -14 to -22
import {
QandaAtom,
GuideAtom,
ProfileAtom,
TimelineAtom,
ChartAtom,
PersonalityQuizAtom,
KnowledgeQuizAtom,
} from '@guardian/atoms-rendering';

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.

If I'm reading this right, does this mean we were importing all these atoms on the page no matter what?! Glad to see it go!

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! 😱

Comment thread dotcom-rendering/src/web/components/App.tsx
Comment on lines -528 to -554
{qandaAtoms.map((qandaAtom) => (
<HydrateOnce rootId={qandaAtom.elementId}>
<QandaAtom
id={qandaAtom.id}
title={qandaAtom.title}
html={qandaAtom.html}
image={qandaAtom.img}
credit={qandaAtom.credit}
pillar={pillar}
likeHandler={componentEventHandler(
'QANDA_ATOM',
qandaAtom.id,
'LIKE',
)}
dislikeHandler={componentEventHandler(
'QANDA_ATOM',
qandaAtom.id,
'DISLIKE',
)}
expandCallback={componentEventHandler(
'QANDA_ATOM',
qandaAtom.id,
'EXPAND',
)}
/>
</HydrateOnce>
))}

@OllysCoding OllysCoding Feb 2, 2022 •

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.

I see that for Qanda atoms (no idea what these are) are no longer reporting ophan data. Is this perhaps something we can do in the wrapper to make sure we're not loosing functionality?

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.

The tracking requests still get sent. It's just I made these tracking props optional and then added a default inside the atoms themselves.

guardian/atoms-rendering#325

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.

👍 Thanks for clarifying!

@github-actions

github-actions Bot commented Feb 2, 2022

Copy link
Copy Markdown

Size Change: -117 kB (-4%)

Total Size: 2.82 MB

Filename Size Change
dotcom-rendering/dist/1053.js 0 B -3.63 kB (removed) 🏆
dotcom-rendering/dist/1053.legacy.js 0 B -3.82 kB (removed) 🏆
dotcom-rendering/dist/1924.js 4.56 kB +392 B (+9%) 🔍
dotcom-rendering/dist/1924.legacy.js 4.7 kB +401 B (+9%) 🔍
dotcom-rendering/dist/1983.js 13.8 kB +4 B (0%)
dotcom-rendering/dist/1983.legacy.js 14.4 kB +4 B (0%)
dotcom-rendering/dist/2260.js 0 B -4.32 kB (removed) 🏆
dotcom-rendering/dist/2998.js 0 B -35.2 kB (removed) 🏆
dotcom-rendering/dist/3213.js 13 kB -2.86 kB (-18%) 👏
dotcom-rendering/dist/3213.legacy.js 13.2 kB -3.02 kB (-19%) 👏
dotcom-rendering/dist/3215.js 4.88 kB +398 B (+9%) 🔍
dotcom-rendering/dist/3215.legacy.js 5.05 kB +403 B (+9%) 🔍
dotcom-rendering/dist/3639.js 4.62 kB +398 B (+9%) 🔍
dotcom-rendering/dist/3639.legacy.js 4.81 kB +401 B (+9%) 🔍
dotcom-rendering/dist/4191.js 0 B -4.67 kB (removed) 🏆
dotcom-rendering/dist/4889.js 0 B -4.55 kB (removed) 🏆
dotcom-rendering/dist/4889.legacy.js 0 B -4.56 kB (removed) 🏆
dotcom-rendering/dist/4891.legacy.js 0 B -34 kB (removed) 🏆
dotcom-rendering/dist/4999.js 17.9 kB +1.03 kB (+6%) 🔍
dotcom-rendering/dist/4999.legacy.js 18.5 kB +1.04 kB (+6%) 🔍
dotcom-rendering/dist/602.js 8.66 kB +1.77 kB (+26%) 🚨
dotcom-rendering/dist/6916.js 8.25 kB -2 B (0%)
dotcom-rendering/dist/7051.js 7.22 kB +402 B (+6%) 🔍
dotcom-rendering/dist/7051.legacy.js 7.37 kB +410 B (+6%) 🔍
dotcom-rendering/dist/7752.legacy.js 0 B -4.48 kB (removed) 🏆
dotcom-rendering/dist/8680.legacy.js 0 B -3.18 kB (removed) 🏆
dotcom-rendering/dist/9323.js 3.65 kB +1 B (0%)
dotcom-rendering/dist/9323.legacy.js 3.76 kB +2 B (0%)
dotcom-rendering/dist/frontend.server.js 1.92 MB +288 B (0%)
dotcom-rendering/dist/guardian-braze-components-banner.js 10.6 kB +525 B (+5%) 🔍
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 10.6 kB +519 B (+5%) 🔍
dotcom-rendering/dist/initDiscussion.js 7.46 kB +138 B (+2%)
dotcom-rendering/dist/initDiscussion.legacy.js 7.71 kB +133 B (+2%)
dotcom-rendering/dist/islands.js 7.61 kB +140 B (+2%)
dotcom-rendering/dist/islands.legacy.js 8.36 kB +136 B (+2%)
dotcom-rendering/dist/react.js 86.7 kB -8.57 kB (-9%) ✅
dotcom-rendering/dist/react.legacy.js 93.5 kB -9.01 kB (-9%) ✅
dotcom-rendering/dist/YoutubeBlockComponent.js 2.84 kB -1 B (0%)
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 2.97 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
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/2666.js 30.6 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/3777.legacy.js 6.41 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/5373.legacy.js 3.58 kB
dotcom-rendering/dist/5585.js 5.2 kB
dotcom-rendering/dist/5585.legacy.js 5.36 kB
dotcom-rendering/dist/602.legacy.js 8.92 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/6916.legacy.js 8.71 kB
dotcom-rendering/dist/6965.js 2.65 kB
dotcom-rendering/dist/6965.legacy.js 2.71 kB
dotcom-rendering/dist/7317.js 3.4 kB
dotcom-rendering/dist/7489.js 3.4 kB
dotcom-rendering/dist/7754.legacy.js 3.56 kB
dotcom-rendering/dist/8080.js 3.52 kB
dotcom-rendering/dist/8080.legacy.js 3.7 kB
dotcom-rendering/dist/8294.js 232 B
dotcom-rendering/dist/8294.legacy.js 244 B
dotcom-rendering/dist/8330.js 3.21 kB
dotcom-rendering/dist/8497.js 4.01 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.17 kB
dotcom-rendering/dist/9641.legacy.js 5.34 kB
dotcom-rendering/dist/9776.js 5.09 kB
dotcom-rendering/dist/9776.legacy.js 5.26 kB
dotcom-rendering/dist/9884.js 17 kB
dotcom-rendering/dist/9884.legacy.js 17.3 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/CalloutBlockComponent.js 4.22 kB
dotcom-rendering/dist/CalloutBlockComponent.legacy.js 4.52 kB
dotcom-rendering/dist/cmp.js 7.51 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-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 2.99 kB
dotcom-rendering/dist/InteractiveBlockComponent.legacy.js 3.12 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.js 2.06 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.legacy.js 2.14 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.25 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.34 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.1 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/readerRevenueDevUtils.js 891 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

compressed-size-action

@OllysCoding OllysCoding 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.

+1 Looks good!

@oliverlloyd
oliverlloyd merged commit 9cad5a7 into main Feb 2, 2022
@oliverlloyd
oliverlloyd deleted the oliver/atoms-as-islands branch February 2, 2022 15:25
@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.

3 participants