Skip to content

🏖 Island - #3784

Merged
oliverlloyd merged 34 commits into
mainfrom
oliver/island
Dec 23, 2021
Merged

oliverlloyd merged 34 commits into
mainfrom
oliver/island

Conversation

@oliverlloyd

@oliverlloyd oliverlloyd commented Dec 22, 2021 •

Copy link
Copy Markdown
Contributor

What does this change?

This PR adds the ability to insert an island of interactivity into the client without having to first server side render it. Previously these client side only islands were referred to as 'Portal's but the concept shares so much with 'Hydrate' that it offers a better developer experience to bring them together.

This means this Portal PR can now be closed.

Why?

Some content is only ever rendered on the client, never on the server. Examples include most read, onwards, etc. In these cases we can't server side render and hydrate these components but we still want to benefit from the deferred dynamic import that the old Hydrate component brings.

Why rename to Island?

Hydrate made sense when the purpose of the abstraction was to offer hydration, but now we're not just hydrating but rendering content directly instead so we need a name that encompasses both these use cases. Island is a term widely used in the industry to represent this pattern and benefits from not having any other Guardian related connotations that could be confusing. We also considered Render, Interactive and DeferRender.

Happy to hear feedback if others have thoughts on this name?

Usage

The api for Island is conditional based on the props passed in

  1. If clientOnly is set to true, then this triggers the 'client only portal' flow and placeholderHeight is required
  2. If clientOnly is set to false, then this triggers the 'server render + hydrate' flow and `placeholderHeight cannot be passed
// Props when using server side rendering
interface HydrateProps {
	deferUntil?: When;
	clientOnly?: false;
	placeholderHeight?: undefined;
	children: JSX.Element;
}

// Props when server side rendering is disabled
interface PortalProps {
	deferUntil?: When;
	clientOnly: true;
	placeholderHeight: number;
	children: JSX.Element;
}
  // Client only
  <Island deferUntil="visible" clientOnly={true} placeholderHeight={440}>
    <Onwards />
  </Island>

  // With server side rendering
  <Island deferUntil="idle">
    <SubNav />
  </Island>

@github-actions

github-actions Bot commented Dec 22, 2021 •

Copy link
Copy Markdown

Size Change: -14.7 kB (0%)

Total Size: 3.14 MB

Filename Size Change
dotcom-rendering/dist/686.js 3.64 kB +4 B (0%)
dotcom-rendering/dist/686.legacy.js 3.74 kB +5 B (0%)
dotcom-rendering/dist/frontend.server.js 2.44 MB +167 B (0%)
dotcom-rendering/dist/hydration.js 0 B -7.05 kB (removed) 🏆
dotcom-rendering/dist/hydration.legacy.js 0 B -7.81 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/101.js 21.1 kB
dotcom-rendering/dist/101.legacy.js 21.1 kB
dotcom-rendering/dist/195.js 1.11 kB
dotcom-rendering/dist/195.legacy.js 1.23 kB
dotcom-rendering/dist/688.js 13.7 kB
dotcom-rendering/dist/688.legacy.js 14.7 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.14 kB
dotcom-rendering/dist/bootCmp.js 7.5 kB
dotcom-rendering/dist/bootCmp.legacy.js 11.1 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.76 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.33 kB
dotcom-rendering/dist/dynamicImport.js 2.99 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.29 kB
dotcom-rendering/dist/EditionDropdown.js 685 B
dotcom-rendering/dist/EditionDropdown.legacy.js 694 B
dotcom-rendering/dist/elements-CalloutBlockComponent.js 4.14 kB
dotcom-rendering/dist/elements-CalloutBlockComponent.legacy.js 4.46 kB
dotcom-rendering/dist/elements-DocumentBlockComponent.js 571 B
dotcom-rendering/dist/elements-DocumentBlockComponent.legacy.js 602 B
dotcom-rendering/dist/elements-InstagramBlockComponent.js 434 B
dotcom-rendering/dist/elements-InstagramBlockComponent.legacy.js 452 B
dotcom-rendering/dist/elements-InteractiveBlockComponent.js 2.96 kB
dotcom-rendering/dist/elements-InteractiveBlockComponent.legacy.js 3.1 kB
dotcom-rendering/dist/elements-InteractiveContentsBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-InteractiveContentsBlockComponent.legacy.js 1.95 kB
dotcom-rendering/dist/elements-MapEmbedBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-MapEmbedBlockComponent.legacy.js 1.94 kB
dotcom-rendering/dist/elements-RichLinkComponent.js 3.26 kB
dotcom-rendering/dist/elements-RichLinkComponent.legacy.js 3.3 kB
dotcom-rendering/dist/elements-SpotifyBlockComponent.js 1.8 kB
dotcom-rendering/dist/elements-SpotifyBlockComponent.legacy.js 1.86 kB
dotcom-rendering/dist/elements-VideoFacebookBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-VideoFacebookBlockComponent.legacy.js 1.94 kB
dotcom-rendering/dist/elements-VineBlockComponent.js 579 B
dotcom-rendering/dist/elements-VineBlockComponent.legacy.js 594 B
dotcom-rendering/dist/elements-YoutubeBlockComponent.js 2.57 kB
dotcom-rendering/dist/elements-YoutubeBlockComponent.legacy.js 2.7 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/GetMatchStats.js 3.29 kB
dotcom-rendering/dist/GetMatchStats.legacy.js 3.36 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 9.78 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 9.79 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.56 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.57 kB
dotcom-rendering/dist/islands.js 7.06 kB
dotcom-rendering/dist/islands.legacy.js 7.81 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.27 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.36 kB
dotcom-rendering/dist/MostViewedRightWrapper.js 3.89 kB
dotcom-rendering/dist/MostViewedRightWrapper.legacy.js 4.07 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.1 kB
dotcom-rendering/dist/OnwardsLower.js 9.63 kB
dotcom-rendering/dist/OnwardsLower.legacy.js 9.86 kB
dotcom-rendering/dist/OnwardsUpper.js 14.1 kB
dotcom-rendering/dist/OnwardsUpper.legacy.js 14.3 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/react.js 139 kB
dotcom-rendering/dist/react.legacy.js 144 kB
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 687 B
dotcom-rendering/dist/sentryLoader.js 4.74 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.82 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.85 kB

compressed-size-action

Comment on lines +693 to +694
[k: `${string}Variant`]: 'variant';
[k: `${string}Control`]: 'control';

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.

Prettier 🤷

@oliverlloyd oliverlloyd changed the title 🏖Island 🏖 Island Dec 22, 2021

@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 to me :) Would be nice to have an E2E test for subnav!

@SiAdcock

Copy link
Copy Markdown
Contributor

I'm guessing this:

  // Client only
  <Island defer="visible" ssr={true} placeholderHeight={440}>
    <Onwards />
  </Island>

Ought to be this:

  // Client only
  <Island defer="visible" ssr={false} placeholderHeight={440}>
    <Onwards />
  </Island>

?

I find the ssr thing a bit hard to grok. The mental model is that you have to remember to turn off SSR if you don't need it. I dunno why but props that default to true always feel a bit confusing to me.

What do you think about the following:

  // Client only
  <Island defer="visible" clientOnly={true} placeholderHeight={440}>
    <Onwards />
  </Island>

Comment thread dotcom-rendering/index.d.ts Outdated
Comment thread dotcom-rendering/src/web/components/Island.tsx Outdated
Comment thread dotcom-rendering/src/web/components/Island.tsx Outdated
Comment thread dotcom-rendering/docs/architecture/027-better-partial-hydration.md Outdated
Comment thread dotcom-rendering/src/web/components/Island.tsx Outdated
@tjmw

tjmw commented Dec 22, 2021

Copy link
Copy Markdown
Member

Excited to see this progressing, nice work! 🎉

@jamesgorrie

jamesgorrie commented Jan 20, 2022 •

Copy link
Copy Markdown
Contributor

part of: #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.

5 participants