Skip to content

Commit ef79ffc

Browse files
committed
Make lazy loading the default
1 parent 1ab9848 commit ef79ffc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/next/client/image.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default function Image({
142142
sizes,
143143
unoptimized = false,
144144
priority = false,
145-
lazy = false,
145+
lazy,
146146
className,
147147
quality,
148148
width,
@@ -156,11 +156,14 @@ export default function Image({
156156
// If priority and lazy are present, log an error and use priority only.
157157
if (priority && lazy) {
158158
if (process.env.NODE_ENV !== 'production') {
159-
console.error(
160-
`Image with src ${src} has both priority and lazy tags. Only one should be used.`
159+
throw new Error(
160+
`Image with src ${src} has both priority and lazy properties. Only one should be used.`
161161
)
162162
}
163-
lazy = false
163+
}
164+
165+
if (!priority && typeof lazy === 'undefined') {
166+
lazy = true
164167
}
165168

166169
useEffect(() => {

0 commit comments

Comments
 (0)