Skip to content

Resize WebP assets, defer reCAPTCHA, and drop copy islands - #14103

Open
kevmoo wants to merge 4 commits into
mainfrom
gsc-perf
Open

kevmoo wants to merge 4 commits into
mainfrom
gsc-perf

Conversation

@kevmoo

@kevmoo kevmoo commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Cuts mobile image payload, startup script blocking, scroll jank, and client
island hydration across flutter.dev and docs.flutter.dev.

  • WebP resizing in ResizingAssetTransformer: Decodes and re-encodes
    .webp inputs via package:image instead of returning originals untouched,
    preserving lossless WebP when lossless and extracting the composited poster
    frame for animated WebP thumbnails (11.38 MB to 56.4 KB, -99.5%, across
    the 3 homepage news cards; 60 resized .webp outputs total).
  • On-focus reCAPTCHA and passive ScrollNotifier: Removes synchronous
    <script src="https://www.google.com/recaptcha/api.js"> (~360 KB) from
    NewsletterSection in favor of loading recaptcha/api.js?render=explicit on
    first input focus, and coalesces passive {passive: true} scroll checks
    inside requestAnimationFrame.
  • Delegated static code-block copy buttons: Replaces per-block @client
    CopyButton islands with server-rendered buttons and a single document click
    listener (stripping [aria-hidden="true"] prompt and fold spans), removing
    3,335 client islands across docs.flutter.dev and 785 across
    flutter.dev/blog (verified on Chrome JS and dart2wasm).

Presubmit checklist

  • If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
  • If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
  • This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
  • This PR uses semantic line breaks
    of 80 characters or fewer.

…islands

- Enable WebP resizing in `ResizingAssetTransformer` (`package:image` `WebPDecoder`/`WebPEncoder`), preserving lossless WebP encoding and extracting the final composited poster frame when downsizing multi-megabyte animated WebP card thumbnails (`11.38 MB` -> `56.4 KB` across homepage featured news cards).
- Remove synchronous `recaptcha/api.js` (`360 KB`) from `NewsletterSection` and lazy-load `recaptcha/api.js?render=explicit` once on first input focus in `NewsletterForm`.
- Attach the `ScrollNotifier` `scroll` listener with `{passive: true}`, coalesce offset updates inside `requestAnimationFrame`, and notify listeners only when active scroll IDs change.
- Replace per-code-block `@client` `CopyButton` islands in `WrappedCodeBlock` and `DownloadableSnippet` with server-rendered `CodeBlockCopyButton` elements backed by a single delegated document click listener across `docs.flutter.dev` (`3,335` islands removed) and `flutter.dev` (`785` islands removed).

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new CodeBlockCopyButton component to replace the existing copy button, updates the ResizingAssetTransformer to support WebP and handle animated thumbnails, and implements lazy reCAPTCHA loading for the newsletter form. The review identified several technical issues, including a compilation error in the image resizing test, missing unawaited annotations for asynchronous calls in violation of the style guide, a type mismatch in the scroll spy utility, and a state management issue in the newsletter form where asynchronous updates were not wrapped in setState.

Comment thread sites/www/lib/src/utils/scroll_spy.dart Resolved
@flutter-website-bot

flutter-website-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Staged preview of the updated docs.flutter.dev site (updated for commit b3c66b7):

https://flutter-docs-prod--docs-pr14103-gsc-perf-4ykr9ios.web.app

@flutter-website-bot

flutter-website-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Staged preview of the updated flutter.dev site (updated for commit b3c66b7):

https://flutter-dev-230821--www-pr14103-gsc-perf-seft11a9.web.app

- Adds explanatory comments on detached unawaited futures in
  newsletter_form.dart and web_code_block_copy.dart, dropping
  @awaitNotRequired to satisfy unnecessary_unawaited.
- Wrap `web.Element.remove` in a closure inside `web_code_block_copy_browser_test` so `dart2js` and `dart2wasm` do not fail on tearing off an external JS interop extension-type member, and add Chrome click-delegation tests.
- Replace text-button content during copy feedback instead of appending `.copy-feedback` alongside existing `buttonText`, and hoist `_handleCopy` to keep cognitive complexity low.
- Decode resized images with a fresh `Decoder` instance after the header width check so stateful decoders such as `PngDecoder` do not duplicate chunk and frame lists.
- Delegate `ScrollNotifier._syncTargets` state updates to `applyThresholds` and remove failed reCAPTCHA `<script>` elements before retry.
@parlough parlough self-assigned this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants