Skip to content

do not use raw url in srcset#3448

Open
JLarky wants to merge 2 commits into
BuilderIO:mainfrom
JLarky:patch-2
Open

do not use raw url in srcset#3448
JLarky wants to merge 2 commits into
BuilderIO:mainfrom
JLarky:patch-2

Conversation

@JLarky

@JLarky JLarky commented Jul 26, 2024

Copy link
Copy Markdown
Contributor

Description

Sorry for the fly by PR :) I think I'm probably brigning this up more like a discussion than a proper PR. I've beein looking into image performance issues with builder content and the thing that I noticed is that you are putting raw url in the srcset without adding 1x or 1w attributes. Those images are showing up in the Properly size images Potential savings of xxx KiB report of lighthouse (especially on the desktop). I think the proper solution according to all the standards and docs is to use intrinsic size of the image, so let's say I have an image of 1234px then proper srcset would be ... 100w ... 200w ... 400w ... 800w ... 1200w ... 1234w (drops 1600 and 2000), but that information is not awailable in the current Image props, so I'm proposing ... 100w ... 200w ... 400w ... 800w ... 1200w ... 1600w ... 2000w ... 9999w which I think is the best you can do in the current circumstances. The main point is that browser will basically ignroe the src set that doesn't have that last ...w directive, and the result is that you are sending tons of html with all those srcsets just for browser to ignore it :)

@JLarky JLarky requested a review from samijaber as a code owner July 26, 2024 20:30
@JLarky JLarky requested a review from a team July 26, 2024 20:30
@changeset-bot

changeset-bot Bot commented Jul 26, 2024

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 82473d4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread packages/sdks/src/blocks/image/image.helpers.ts Outdated
@JLarky

JLarky commented Jul 31, 2024

Copy link
Copy Markdown
Contributor Author

great point! thank you so much for your suggestion

@samijaber

Copy link
Copy Markdown
Contributor

@JLarky thanks for making the changes! unfortunately it looks like a few of our integration tests are now getting errors specifically around the expected image width.

It's inconsistent: looks like only client-side rendered tests are failing, not SSR'd content.

Feel free to dig into it and try to get to the bottom of the issue. If not, we will need to find the time to investigate your PR further as soon as we have the bandwidth.

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.

2 participants