Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes: Lazy load screenshots #96961

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open

Conversation

mmtr
Copy link
Member

@mmtr mmtr commented Dec 2, 2024

Fixes #95248

Proposed Changes

Defers the loading of the theme screenshots in the theme showcase until the user scrolls near them with a loading='lazy' attribute, effectively decreasing the initial data load from 35MB to 2.5MB (-92%).

Before

Screen.Recording.2024-12-02.at.11.11.31.mov

After

Screen.Recording.2024-12-02.at.11.24.57.mov

Why are these changes being made?

To optimize the data transferred over network.

Testing Instructions

  • Use the Calypso live link below
  • Open the browser devtools and select the Network tab
  • Filter by screenshot requests
  • Go to /themes/:site
  • Make sure that the screenshot requests are lazy loaded (off-screen images are loaded when you scroll near them)
  • Repeat with /themes while logged in and logged out

@mmtr mmtr added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 2, 2024
@mmtr mmtr requested a review from a team December 2, 2024 10:34
@mmtr mmtr self-assigned this Dec 2, 2024
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/lazy-load-theme-screenshots on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Dec 2, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~3 bytes added 📈 [gzipped])

name    parsed_size           gzip_size
themes        +15 B  (+0.0%)       +3 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~3 bytes added 📈 [gzipped])

name                                     parsed_size           gzip_size
async-load-signup-steps-theme-selection        +15 B  (+0.0%)       +3 B  (+0.0%)
async-load-design-blocks                       +15 B  (+0.0%)       +3 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimise data transfer on /themes
2 participants