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

Setup automatic image optimization pipeline #5779

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

parlough
Copy link
Member

@parlough parlough commented May 7, 2024

Use 11ty's first-party image transformation plugin to automatically optimize images, convert them to png, webp, and avif, and then transform the site HTML to use the <picture> element to select the best one for the user. This only runs in production deploy builds to reduce serving time. Also applies lazy loading and async decoding to all images, even when serving without optimizations. The transform also adds a hash of the image, allowing us to expand caching for images in Firebase hosting.

To account for the transformed HTML structure, some minor HTML and CSS changes were needed as well.

Overall, this reduces page load time on pages that use images, and reduces unnecessary downloads that were due to a relatively short cache time for images. On a page with just a few images, such as https://dart.dev/tools/pub/automated-publishing, the lighthouse perf score increases around 10-15 points.

Fixes #4473
Fixes #3124

@parlough parlough added the review.tech Awaiting Technical Review label May 7, 2024
@dart-github-bot
Copy link
Collaborator

dart-github-bot commented May 7, 2024

Visit the preview URL for this PR (updated for commit 3a1d92a):

https://dart-dev--pr5779-feat-image-opt-db6dftoy.web.app

@parlough parlough marked this pull request as ready for review May 7, 2024 19:05
@atsansone
Copy link
Contributor

@parlough : I see no reason not to make this change, but I'm not seeing any benefit. Both the staged version and live version of https://dart.dev/web/debugging and https://dart.dev/tools/pub/automated-publishing, Lighthouse scores were 97 for all.

Current
image

Staged
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review.tech Awaiting Technical Review
Projects
None yet
3 participants