-
Notifications
You must be signed in to change notification settings - Fork 27.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
Add support for AVIF to next/image
#29683
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs LGTM
if (transformer.avif) { | ||
transformer.avif({ quality }) | ||
} else { | ||
console.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wrap this in an execOnce
so it doesn't log multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to decide if this should be warning or error and I picked the one in between: annoying warning every time.
It will only log when a device that supports AVIF visits the website that doesn't support AVIF so I guess it’s not every time.
Co-authored-by: JJ Kasper <[email protected]>
This comment has been minimized.
This comment has been minimized.
Failing test suitesCommit: 32169e9 test/development/basic/hmr.test.ts
Expand output● basic HMR › Error Recovery › should recover from errors in the render function
● basic HMR › Error Recovery › should recover after exporting an invalid page
● basic HMR › Error Recovery › should recover after exporting an invalid page
● basic HMR › Error Recovery › should recover after undefined exported as default
|
Stats from current PRDefault Build (Increase detected
|
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
buildDuration | 12.3s | 12.2s | -137ms |
buildDurationCached | 2.9s | 2.8s | -77ms |
nodeModulesSize | 195 MB | 195 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.807 | 2.799 | -0.01 |
/ avg req/sec | 890.68 | 893.18 | +2.5 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.286 | 1.293 | |
/error-in-render avg req/sec | 1944.1 | 1932.83 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
779.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42.2 kB | 42.2 kB | ✓ |
main-HASH.js gzip | 27 kB | 27 kB | ✓ |
webpack-HASH.js gzip | 1.45 kB | 1.45 kB | ✓ |
Overall change | 70.9 kB | 70.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
polyfills-a4..dd70.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages Overall increase ⚠️
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
_app-HASH.js gzip | 977 B | 977 B | ✓ |
_error-HASH.js gzip | 194 B | 194 B | ✓ |
amp-HASH.js gzip | 311 B | 311 B | ✓ |
css-HASH.js gzip | 328 B | 328 B | ✓ |
dynamic-HASH.js gzip | 2.67 kB | 2.67 kB | ✓ |
head-HASH.js gzip | 351 B | 351 B | ✓ |
hooks-HASH.js gzip | 918 B | 918 B | ✓ |
image-HASH.js gzip | 4.12 kB | 4.14 kB | |
index-HASH.js gzip | 260 B | 260 B | ✓ |
link-HASH.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..HASH.js gzip | 320 B | 320 B | ✓ |
script-HASH.js gzip | 386 B | 386 B | ✓ |
withRouter-HASH.js gzip | 319 B | 319 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 12.9 kB | 13 kB |
Client Build Manifests Overall decrease ✓
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
_buildManifest.js gzip | 494 B | 493 B | -1 B |
Overall change | 494 B | 493 B | -1 B |
Rendered Page Sizes
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
index.html gzip | 539 B | 539 B | ✓ |
link.html gzip | 551 B | 551 B | ✓ |
withRouter.html gzip | 532 B | 532 B | ✓ |
Overall change | 1.62 kB | 1.62 kB | ✓ |
Diffs
Diff for _buildManifest.js
@@ -17,7 +17,7 @@ self.__BUILD_MANIFEST = {
"static\u002Fchunks\u002Fpages\u002Fhooks-c1f9675770bff0c63be8.js"
],
"/image": [
- "static\u002Fchunks\u002Fpages\u002Fimage-e464a773324a5820a436.js"
+ "static\u002Fchunks\u002Fpages\u002Fimage-19e6b3a207d8f370283a.js"
],
"/link": ["static\u002Fchunks\u002Fpages\u002Flink-962a2a330709d57cd073.js"],
"/routerDirect": [
Diff for image-HASH.js
@@ -1034,7 +1034,8 @@
loader: "default",
domains: [],
disableStaticImages: false,
- minimumCacheTTL: 60
+ minimumCacheTTL: 60,
+ formats: ["image/avif", "image/webp"]
};
exports.imageConfigDefault = imageConfigDefault;
Default Build with SWC (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
buildDuration | 6.2s | 6.1s | -80ms |
buildDurationCached | 2.8s | 2.8s | |
nodeModulesSize | 195 MB | 195 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.778 | 2.792 | |
/ avg req/sec | 899.88 | 895.28 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.303 | 1.305 | 0 |
/error-in-render avg req/sec | 1919.35 | 1916.15 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
675-HASH.js gzip | 13.8 kB | 13.8 kB | |
770.HASH.js gzip | 178 B | 178 B | ✓ |
framework-HASH.js gzip | 50.7 kB | 50.7 kB | ✓ |
main-HASH.js gzip | 35 kB | 35 kB | ✓ |
webpack-HASH.js gzip | 1.64 kB | 1.64 kB | ✓ |
Overall change | 101 kB | 101 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
polyfills-a4..dd70.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.33 kB | 1.33 kB | ✓ |
_error-HASH.js gzip | 180 B | 180 B | ✓ |
amp-HASH.js gzip | 315 B | 315 B | ✓ |
css-HASH.js gzip | 331 B | 331 B | ✓ |
dynamic-HASH.js gzip | 2.79 kB | 2.79 kB | ✓ |
head-HASH.js gzip | 355 B | 355 B | ✓ |
hooks-HASH.js gzip | 637 B | 637 B | ✓ |
image-HASH.js gzip | 555 B | 555 B | ✓ |
index-HASH.js gzip | 261 B | 261 B | ✓ |
link-HASH.js gzip | 2.22 kB | 2.22 kB | ✓ |
routerDirect..HASH.js gzip | 326 B | 326 B | ✓ |
script-HASH.js gzip | 393 B | 393 B | ✓ |
withRouter-HASH.js gzip | 322 B | 322 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 10.1 kB | 10.1 kB | ✓ |
Client Build Manifests
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
_buildManifest.js gzip | 511 B | 511 B | ✓ |
Overall change | 511 B | 511 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | vercel/next.js feat-add-avif-next-image | Change | |
---|---|---|---|
index.html gzip | 537 B | 537 B | ✓ |
link.html gzip | 551 B | 551 B | ✓ |
withRouter.html gzip | 532 B | 532 B | ✓ |
Overall change | 1.62 kB | 1.62 kB | ✓ |
Diffs
Diff for _buildManifest.js
@@ -17,7 +17,7 @@ self.__BUILD_MANIFEST = {
"static\u002Fchunks\u002Fpages\u002Fhooks-7fa8f6299881aeef4d92.js"
],
"/image": [
- "static\u002Fchunks\u002F675-e36478c6435f19ec761d.js",
+ "static\u002Fchunks\u002F675-e9b1cbb7d10482282740.js",
"static\u002Fchunks\u002Fpages\u002Fimage-24dfc0766459a85ca885.js"
],
"/link": ["static\u002Fchunks\u002Fpages\u002Flink-d5bdd3af9bbbd881abda.js"],
Diff for 675-HASH.js
@@ -3273,7 +3273,8 @@
loader: "default",
domains: [],
disableStaticImages: false,
- minimumCacheTTL: 60
+ minimumCacheTTL: 60,
+ formats: ["image/avif", "image/webp"]
};
exports.imageConfigDefault = imageConfigDefault;
Add support for AVIF to
next/image
Feature
sharp
is outdatedimage-size
in favor ofsquoosh
/sharp
(optional, need to benchmark)