Skip to content

remove lazy loading and warm gift-card images#801

Open
gudnuf wants to merge 1 commit intomasterfrom
warm-card-images
Open

remove lazy loading and warm gift-card images#801
gudnuf wants to merge 1 commit intomasterfrom
warm-card-images

Conversation

@gudnuf
Copy link
Contributor

@gudnuf gudnuf commented Jan 30, 2026

Even if the images are cached, the browser will still need to decode them on each fresh load which causes the images to flash in. This PR makes it so the images are decoded before the user goes to the gift-card route.

@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agicash Ready Ready Preview, Comment Jan 30, 2026 7:26pm

Request Review

@supabase
Copy link

supabase bot commented Jan 30, 2026

This pull request has been ignored for the connected project hrebgkfhjpkbxpztqqke because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

<img
src={src}
alt={alt}
loading="lazy"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lazy loading like this causes issues with the view transitions on iOS. The browser would take a snapshot of the gift cards without the images loaded (even though they had previously been cached and decoded in the same session), and then during the transition the images would flash

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remind me why did we add it initially? if it was adding some value, should we disable it only on ios?

* Schedules non-critical work after initial render.
* Uses idle time when available to avoid impacting UI responsiveness.
*/
function scheduleAfterPaint(callback: () => void) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is unnecessary, but I did this so that decoding and loading the images doesn't compete with other loading tasks and only starts when the main thread is idle in between async calls and after all sync work is donw

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does decoding mean in this case? don't we just have regular image to display in browser?


export const links: LinksFunction = () =>
GIFT_CARD_IMAGES.map((imageUrl) => ({
rel: 'prefetch',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This optimizes for when the user opens the app directly to /gift-cards. If the user comes from the home page this isn't necessary because we already preload the images there

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you need to prefetch when coming to this page when this page requires it anyway? my understanding is that prefetch is used when you land on page A and then maybe page B has some images and you want them to be loaded immidiialtey instead of only when user clicks to go to B

@gudnuf gudnuf requested a review from jbojcic1 January 30, 2026 19:20
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