src/content/docs/linter/rules/no-img-element.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JSX and TSX" icon="seti:javascript"> ## Summary - Rule available since: `v1.9.4` - Diagnostic Category: [`lint/performance/noImgElement`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - This rule belongs to the following domains: - [`next`](/linter/domains#next) - Sources: - Same as [`@next/next/no-img-element`](https://nextjs.org/docs/messages/no-img-element){
"linter": {
"rules": {
"performance": {
"noImgElement": "error"
}
}
}
}
Prevent usage of `` element in a Next.js project.
Using the `` element can result in slower Largest Contentful Paint (LCP)
and higher bandwidth usage, as it lacks the optimizations provided by the <Image />
component from next/image. Next.js's <Image /> automatically optimizes images
by serving responsive sizes and using modern formats, improving performance and reducing bandwidth.
If your project is self-hosted, ensure that you have sufficient storage and have
installed the sharp package to support optimized images. When deploying to managed
hosting providers, be aware of potential additional costs or usage.
<div>
</div>
<Image src="https://example.com/hero.jpg" />
<picture>
<source srcSet="https://example.com/hero.avif" type="image/avif" />
<source srcSet="https://example.com/hero.webp" type="image/webp" />
</picture>