-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Optimize images as part of production builds #10391
Conversation
Visit the preview URL for this PR (updated for commit 77bd8a6): https://flutter-docs-prod--pr10391-feat-optimize-images-9kqzqpc9.web.app |
Parker, can we either land this or close? I really hate stinky PRs that hang around for weeks and weeks. |
@sfshaza2 Yep, sorry! I was waiting for the dart.dev equivalent to land to work out the kinks there first. It landed today with dart-lang/site-www@bcbff3e. I'll work on getting this updated and ready for review sometime this week. |
Use 11ty's first-party image transformation plugin to automatically optimize images, convert them to
png
,webp
, andavif
, 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 a few images, I saw lighthouse perf score increases from 5-15 points.
Closes #6487
Closes #9527 as this plugin also validates
alt
is always specified