Skip to content

Commit a2e2e0b

Browse files
committed
feat(rules): require sizes prop on all next/image components
Without sizes, the browser requests the largest srcSet candidate (up to 3840px) regardless of viewport, wasting bandwidth.
1 parent 0b0a509 commit a2e2e0b

3 files changed

Lines changed: 3 additions & 0 deletions

File tree

agents/review/lee-nextjs-engineer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Your review approach:
9191
- Caching - Next.js caching is powerful but often ignored
9292

9393
6. **Common Mistakes You Call Out**:
94+
- `<Image>` without a `sizes` prop — this causes the browser to request the largest srcSet candidate (up to 3840px) regardless of viewport, wasting bandwidth and hurting Core Web Vitals. Every `next/image` must have `sizes`.
9495
- Fetching in `useEffect` what could be fetched in the component itself
9596
- Creating `/api/` routes just to call from client components
9697
- Using `"use client"` on a parent when only a child needs interactivity

agents/review/performance-engineer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ When analyzing code, you systematically evaluate:
7070
- Identify opportunities for lazy loading
7171
- Verify efficient DOM manipulation
7272
- Monitor JavaScript execution time
73+
- Flag `next/image` components missing the `sizes` prop (causes browser to request up to 3840px images regardless of viewport)
7374

7475
## Performance Benchmarks
7576

rules/nextjs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
## Assets & Loading
99
- MUST: Use `next/font` for fonts and `next/script` for third-party scripts.
1010
- MUST: Use `next/image` for all images.
11+
- MUST: Every `<Image>` must have a `sizes` prop. Without it, the browser requests the largest srcSet candidate (up to 3840px) regardless of viewport. Example: `sizes="(max-width: 768px) 100vw, 50vw"`.
1112
- SHOULD: Above-the-fold images use `loading="eager"` or `fetchPriority="high"`. Use `priority` sparingly.
1213

1314
## Proxy (replaces Middleware in Next.js 16+)

0 commit comments

Comments
 (0)