Skip to content

TopRightAdSlot - #3968

Merged
oliverlloyd merged 3 commits into
mainfrom
oliver/maybe-shady
Feb 11, 2022
Merged

oliverlloyd merged 3 commits into
mainfrom
oliver/maybe-shady

Conversation

@oliverlloyd

@oliverlloyd oliverlloyd commented Feb 11, 2022 •

Copy link
Copy Markdown
Contributor

What does this change?

This PR moves shady pie into an island

What is shady pie?

This is the name given to the contribution slot which gets shown in the top right ad slot when an ad blocker is detected (plus some other criteria).

In this PR we're creating a pure ShadyPie component which encapsulates what gets show. We then moved the logic to decide when to show it or not into TopRightAdSlot. (I really wanted to call this component MaybeShady but in truth what it is actually doing is rendering the top right ad slot and then sometime this slot is the contribution - shady pie - image.)

But now we have ad slot html in two different files, boo

I agree, it's not ideal that this html exists in multiple locations as this will make refactors harder later. I did try using children to keep the id="dfp-ad--right" div co-located in AdSlot.tsx however this introduced an unwanted side effect. The whole slot html and css was being serialised and inserted into the gu-island dom element. This is sub optimal and I felt that the trade off between this performance hit and the fact the code is broken apart was worth it.

@oliverlloyd
oliverlloyd requested review from a team, JamieB-gu and marsavar as code owners February 11, 2022 11:07
@github-actions

github-actions Bot commented Feb 11, 2022 •

Copy link
Copy Markdown

Size Change: -36.3 kB (-3%)

Total Size: 1.25 MB

Filename Size Change
dotcom-rendering/dist/1214.js 2.65 kB +516 B (+24%) 🚨
dotcom-rendering/dist/1214.legacy.js 2.71 kB +519 B (+24%) 🚨
dotcom-rendering/dist/1376.js 1.9 kB -1.74 kB (-48%) 🎉
dotcom-rendering/dist/1376.legacy.js 2.01 kB -1.82 kB (-48%) 🎉
dotcom-rendering/dist/1672.js 0 B -3.72 kB (removed) 🏆
dotcom-rendering/dist/1924.js 5.1 kB +531 B (+12%) ⚠️
dotcom-rendering/dist/1924.legacy.js 5.18 kB +488 B (+10%) ⚠️
dotcom-rendering/dist/2.js 4.36 kB +550 B (+14%) ⚠️
dotcom-rendering/dist/2.legacy.js 4.47 kB +546 B (+14%) ⚠️
dotcom-rendering/dist/2058.js 5.78 kB +523 B (+10%) ⚠️
dotcom-rendering/dist/2058.legacy.js 5.94 kB +514 B (+9%) 🔍
dotcom-rendering/dist/262.js 5.61 kB -1.65 kB (-23%) 🎉
dotcom-rendering/dist/2879.js 9.01 kB +2.06 kB (+30%) 🚨
dotcom-rendering/dist/2879.legacy.js 9.56 kB +2.38 kB (+33%) 🚨
dotcom-rendering/dist/3203.js 9.16 kB +873 B (+11%) ⚠️
dotcom-rendering/dist/3203.legacy.js 9.63 kB +874 B (+10%) ⚠️
dotcom-rendering/dist/3213.js 13.5 kB +557 B (+4%)
dotcom-rendering/dist/3213.legacy.js 13.8 kB +565 B (+4%)
dotcom-rendering/dist/3215.js 5.39 kB +531 B (+11%) ⚠️
dotcom-rendering/dist/3215.legacy.js 5.52 kB +499 B (+10%) ⚠️
dotcom-rendering/dist/343.js 2 kB -1.73 kB (-46%) 🎉
dotcom-rendering/dist/343.legacy.js 2.1 kB -1.81 kB (-46%) 🎉
dotcom-rendering/dist/4415.legacy.js 0 B -3.56 kB (removed) 🏆
dotcom-rendering/dist/45.legacy.js 0 B -3.55 kB (removed) 🏆
dotcom-rendering/dist/4813.js 5.29 kB -1.51 kB (-22%) 🎉
dotcom-rendering/dist/4813.legacy.js 5.38 kB -1.54 kB (-22%) 🎉
dotcom-rendering/dist/4999.js 18.4 kB +538 B (+3%)
dotcom-rendering/dist/4999.legacy.js 19 kB +572 B (+3%)
dotcom-rendering/dist/5585.js 6.47 kB +1.21 kB (+23%) 🚨
dotcom-rendering/dist/5585.legacy.js 6.72 kB +1.3 kB (+24%) 🚨
dotcom-rendering/dist/6146.legacy.js 0 B -5.85 kB (removed) 🏆
dotcom-rendering/dist/6348.js 5.12 kB +541 B (+12%) ⚠️
dotcom-rendering/dist/6348.legacy.js 5.29 kB +541 B (+11%) ⚠️
dotcom-rendering/dist/6372.legacy.js 0 B -3.89 kB (removed) 🏆
dotcom-rendering/dist/6698.js 0 B -3.15 kB (removed) 🏆
dotcom-rendering/dist/6698.legacy.js 0 B -3.23 kB (removed) 🏆
dotcom-rendering/dist/6965.js 3.18 kB +540 B (+20%) 🚨
dotcom-rendering/dist/6965.legacy.js 3.24 kB +531 B (+20%) 🚨
dotcom-rendering/dist/7051.js 7.76 kB +539 B (+7%) 🔍
dotcom-rendering/dist/7051.legacy.js 7.91 kB +539 B (+7%) 🔍
dotcom-rendering/dist/7317.js 0 B -3.4 kB (removed) 🏆
dotcom-rendering/dist/7489.js 0 B -3.4 kB (removed) 🏆
dotcom-rendering/dist/7642.legacy.js 8.31 kB -1.67 kB (-17%) 👏
dotcom-rendering/dist/7754.legacy.js 0 B -3.56 kB (removed) 🏆
dotcom-rendering/dist/8080.js 1.81 kB -1.72 kB (-49%) 🎉
dotcom-rendering/dist/8080.legacy.js 1.9 kB -1.8 kB (-49%) 🎉
dotcom-rendering/dist/9212.js 0 B -3.4 kB (removed) 🏆
dotcom-rendering/dist/9641.js 6.44 kB +1.21 kB (+23%) 🚨
dotcom-rendering/dist/9641.legacy.js 6.7 kB +1.3 kB (+24%) 🚨
dotcom-rendering/dist/9682.js 0 B -5.4 kB (removed) 🏆
dotcom-rendering/dist/9776.js 6.37 kB +1.21 kB (+24%) 🚨
dotcom-rendering/dist/9776.legacy.js 6.63 kB +1.3 kB (+24%) 🚨
dotcom-rendering/dist/9970.js 15.8 kB +1.43 kB (+10%) ⚠️
dotcom-rendering/dist/9970.legacy.js 16.1 kB +1.46 kB (+10%) ⚠️
dotcom-rendering/dist/frontend.server.js 320 kB +880 B (0%)
dotcom-rendering/dist/initDiscussion.js 7.67 kB +12 B (0%)
dotcom-rendering/dist/initDiscussion.legacy.js 7.92 kB +15 B (0%)
dotcom-rendering/dist/islands.js 7.82 kB +12 B (0%)
dotcom-rendering/dist/islands.legacy.js 8.55 kB +19 B (0%)
dotcom-rendering/dist/react.js 76.4 kB -745 B (-1%)
dotcom-rendering/dist/react.legacy.js 82.9 kB -726 B (-1%)
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/1624.js 2.64 kB
dotcom-rendering/dist/1624.legacy.js 2.71 kB
dotcom-rendering/dist/2177.js 3.7 kB
dotcom-rendering/dist/2666.js 30.8 kB
dotcom-rendering/dist/2727.legacy.js 28.7 kB
dotcom-rendering/dist/2947.js 2.58 kB
dotcom-rendering/dist/2947.legacy.js 2.66 kB
dotcom-rendering/dist/3397.js 240 B
dotcom-rendering/dist/3397.legacy.js 251 B
dotcom-rendering/dist/3729.js 1.28 kB
dotcom-rendering/dist/3729.legacy.js 1.36 kB
dotcom-rendering/dist/4025.js 3.98 kB
dotcom-rendering/dist/4025.legacy.js 4.31 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/5096.js 4.67 kB
dotcom-rendering/dist/5096.legacy.js 4.74 kB
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/6046.js 2.94 kB
dotcom-rendering/dist/6046.legacy.js 3.04 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/7671.legacy.js 3.83 kB
dotcom-rendering/dist/7800.js 11 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/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/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-banner.js 10.8 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 10.8 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.94 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.95 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 2.61 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 2.72 kB
dotcom-rendering/dist/YoutubeBlockComponent.js 2.9 kB
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 3.03 kB

compressed-size-action

@mxdvl

mxdvl commented Feb 11, 2022 •

Copy link
Copy Markdown
Contributor

I think we want to always render the ad slot. We conditionally also add the shady pie.

The whole slot html and css was being serialised and inserted into the gu-island DOM element.

Not rendering this ad slot server side may have other consequences. I think this would be preferable to an approach where the slot is rendered at some unknown time. Pinging @guardian/commercial-dev for visibility.

@mxdvl
mxdvl requested a review from a team February 11, 2022 11:44
sndrs
sndrs previously approved these changes Feb 11, 2022
@sndrs
sndrs dismissed their stale review February 11, 2022 11:54

should have spotted max's comment, i was too premature

@oliverlloyd oliverlloyd changed the title MaybeShady TopRightAdSlot Feb 11, 2022
@oliverlloyd

oliverlloyd commented Feb 11, 2022 •

Copy link
Copy Markdown
Contributor Author

I think we want to always render the ad slot

As discussed, we do. The default top right as slot is always rendered server side and only replaced with shady pie on the client in the event that we detect an adblocker

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

Okay, I get it now: the ad slot is rendered on the server, then hydrated on the client. There’s no risk of it being missing by the time commercial code runs.

@oliverlloyd
oliverlloyd merged commit 0a8c483 into main Feb 11, 2022
@oliverlloyd
oliverlloyd deleted the oliver/maybe-shady branch February 11, 2022 16:45
@mxdvl

mxdvl commented Mar 25, 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