Description
The Image Element Audit snippet reports a false positive info message for SVG images:
No modern format detected (WebP / AVIF / JXL)
SVG is a vector format and converting it to WebP/AVIF/JXL would be counterproductive — the recommendation doesn't apply.
Root cause
In the snippet, isModernFormat() only checks for raster modern formats, and there is no exclusion for SVG before pushing the issue:
function isModernFormat(format) {
return ["avif", "webp", "jxl", "auto (cdn)", "auto (cdn?)"].includes(format);
}
// SVG is not excluded, so this fires for SVG images
if (!isModernFormat(format) && !inPicture)
issues.push({ s: "info", msg: "No modern format detected (WebP / AVIF / JXL)" });
Suggested fix
Add a format !== "svg" guard:
if (!isModernFormat(format) && !inPicture && format !== "svg")
issues.push({ s: "info", msg: "No modern format detected (WebP / AVIF / JXL)" });
Steps to reproduce
- Open a page that has
<img> elements with .svg sources
- Run the Image Element Audit snippet in DevTools
- SVG images will show the "No modern format detected" info message
Description
The Image Element Audit snippet reports a false positive info message for SVG images:
SVG is a vector format and converting it to WebP/AVIF/JXL would be counterproductive — the recommendation doesn't apply.
Root cause
In the snippet,
isModernFormat()only checks for raster modern formats, and there is no exclusion for SVG before pushing the issue:Suggested fix
Add a
format !== "svg"guard:Steps to reproduce
<img>elements with.svgsources