Skip to content

Commit 106e17c

Browse files
leerobstyfle
andauthored
docs: recommend webp over avif (#75966)
Co-authored-by: Steven <[email protected]>
1 parent bd1a84d commit 106e17c

File tree

10 files changed

+18
-12
lines changed

10 files changed

+18
-12
lines changed

docs/01-app/01-getting-started/04-images-and-fonts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You can store static files, like images and fonts, under a folder called `public
2828

2929
The Next.js [`<Image>`](/docs/app/building-your-application/optimizing/images) component extends the HTML `<img>` element to provide:
3030

31-
- **Size optimization:** Automatically serving correctly sized images for each device, using modern image formats like WebP and AVIF.
31+
- **Size optimization:** Automatically serving correctly sized images for each device, using modern image formats like WebP.
3232
- **Visual stability:** Preventing [layout shift](https://web.dev/articles/cls) automatically when images are loading.
3333
- **Faster page loads:** Only loading images when they enter the viewport using native browser lazy loading, with optional blur-up placeholders.
3434
- **Asset flexibility:** Resizing images on-demand, even images stored on remote servers.

docs/01-app/03-building-your-application/06-optimizing/01-images.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ According to [Web Almanac](https://almanac.httparchive.org), images account for
2222

2323
The Next.js Image component extends the HTML `<img>` element with features for automatic image optimization:
2424

25-
- **Size Optimization:** Automatically serve correctly sized images for each device, using modern image formats like WebP and AVIF.
25+
- **Size Optimization:** Automatically serve correctly sized images for each device, using modern image formats like WebP.
2626
- **Visual Stability:** Prevent [layout shift](/learn/seo/web-performance/cls) automatically when images are loading.
2727
- **Faster Page Loads:** Images are only loaded when they enter the viewport using native browser lazy loading, with optional blur-up placeholders.
2828
- **Asset Flexibility:** On-demand image resizing, even for images stored on remote servers

docs/01-app/03-building-your-application/10-deploying/01-production-checklist.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ While building your application, we recommend using the following features to en
8787
</AppOnly>
8888

8989
- **[Font Module](/docs/app/building-your-application/optimizing/fonts):** Optimize fonts by using the Font Module, which automatically hosts your font files with other static assets, removes external network requests, and reduces [layout shift](https://web.dev/articles/cls).
90-
- **[`<Image>` Component](/docs/app/building-your-application/optimizing/images):** Optimize images by using the Image Component, which automatically optimizes images, prevents layout shift, and serves them in modern formats like WebP or AVIF.
90+
- **[`<Image>` Component](/docs/app/building-your-application/optimizing/images):** Optimize images by using the Image Component, which automatically optimizes images, prevents layout shift, and serves them in modern formats like WebP.
9191
- **[`<Script>` Component](/docs/app/building-your-application/optimizing/scripts):** Optimize third-party scripts by using the Script Component, which automatically defers scripts and prevents them from blocking the main thread.
9292
- **[ESLint](/docs/architecture/accessibility#linting):** Use the built-in `eslint-plugin-jsx-a11y` plugin to catch accessibility issues early.
9393

docs/01-app/04-api-reference/02-components/image.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,18 +715,19 @@ module.exports = {
715715
}
716716
```
717717

718-
You can enable AVIF support and still fallback to WebP with the following configuration.
718+
You can enable AVIF support, which will fallback to the original format of the src image if the browser [does not support AVIF](https://caniuse.com/avif):
719719

720720
```js filename="next.config.js"
721721
module.exports = {
722722
images: {
723-
formats: ['image/avif', 'image/webp'],
723+
formats: ['image/avif'],
724724
},
725725
}
726726
```
727727

728728
> **Good to know**:
729729
>
730+
> - We still recommend using WebP for most use cases.
730731
> - AVIF generally takes 50% longer to encode but it compresses 20% smaller compared to WebP. This means that the first time an image is requested, it will typically be slower and then subsequent requests that are cached will be faster.
731732
> - If you self-host with a Proxy/CDN in front of Next.js, you must configure the Proxy to forward the `Accept` header.
732733

docs/02-pages/03-api-reference/01-components/image-legacy.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,17 +512,21 @@ module.exports = {
512512
}
513513
```
514514

515-
You can enable AVIF support and still fallback to WebP with the following configuration.
515+
You can enable AVIF support, which will fallback to the original format of the src image if the browser [does not support AVIF](https://caniuse.com/avif):
516516

517517
```js filename="next.config.js"
518518
module.exports = {
519519
images: {
520-
formats: ['image/avif', 'image/webp'],
520+
formats: ['image/avif'],
521521
},
522522
}
523523
```
524524

525-
> **Good to know**: AVIF generally takes 50% longer to encode but it compresses 20% smaller compared to WebP. This means that the first time an image is requested, it will typically be slower and then subsequent requests that are cached will be faster.
525+
> **Good to know**:
526+
>
527+
> - We still recommend using WebP for most use cases.
528+
> - AVIF generally takes 50% longer to encode but it compresses 20% smaller compared to WebP. This means that the first time an image is requested, it will typically be slower and then subsequent requests that are cached will be faster.
529+
> - If you self-host with a Proxy/CDN in front of Next.js, you must configure the Proxy to forward the `Accept` header.
526530
527531
## Caching Behavior
528532

examples/cms-contentful/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
module.exports = {
33
images: {
44
loader: "custom",
5-
formats: ["image/avif", "image/webp"],
5+
search: "",
66
},
77
};

examples/image-component/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @type {import('next').NextConfig} */
22
module.exports = {
33
images: {
4-
formats: ["image/avif", "image/webp"],
4+
search: "",
55
remotePatterns: [
66
{
77
protocol: "https",

examples/image-legacy-component/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
images: {
5-
formats: ["image/avif", "image/webp"],
5+
search: "",
66
remotePatterns: [
77
{
88
protocol: "https",

examples/image-secure-compute/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
images: {
5+
search: "",
56
localPatterns: [
67
{
78
pathname: "/image-api/**",

examples/with-cloudinary/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
images: {
3-
formats: ["image/avif", "image/webp"],
3+
search: "",
44
remotePatterns: [
55
{
66
protocol: "https",

0 commit comments

Comments
 (0)