squirrelscan
GitHub

Image audit rules: alt text, formats and lazy loading

Audit rules for images: alt text, file size, WebP and AVIF, srcset, lazy loading, and the width and height attributes that prevent layout shift.

Images rules cover the two things images most often break: page weight and layout. Weight is file size, format and whether the right size is served to the right screen; layout is the width and height attributes that reserve space before an image arrives. The category also carries the markup checks (alt attributes, picture fallbacks and figure captions) that decide whether an image means anything to a reader who cannot see it.

Run only these rules

squirrel audit https://example.com --rule-include images

A few image checks live in Performance instead: a lazy-loaded hero image, the hero’s fetch priority and preload, and eager images in hidden carousel slides. Run both with --rule-include images,perf.

Where to start

These carry the highest severity and weight in the category.

Rules

RuleWhat it flagsSeverityScope
<picture> without an <img>: the fallback that is requiredA picture element with no img child renders nothing at all. squirrel checks every picture on the page for its required fallback.errorPer-page
Broken images: empty and placeholder src attributesAn img with an empty or placeholder src renders as a broken icon. squirrel collects image sources across the crawl and flags the malformed ones.errorSite-wide
figure and figcaption: captions that are associatedA caption in a plain div is text near an image; a figcaption is the image’s caption. squirrel checks figures for captions and notes standalone images.infoPer-page
Image aspect ratio mismatch: attributes versus the CSS boxWhen width and height describe one ratio and CSS forces another, the image stretches. squirrel compares the two and allows for object-fit.warningPer-page
Image optimization signals: CDNs and modern formatssquirrel reads image URLs for the marks of an optimization pipeline: a known image CDN, a modern format, or a format parameter in the query.infoPer-page
Image width and height attributes: preventing layout shiftAn image with no width and height reserves no space, so the page jumps when it loads. squirrel checks both attributes on every image.warningPer-page
IMG_1234.jpg: image filenames that describe nothingA filename straight off a camera or a hash tells nobody what the picture is. squirrel matches image filenames against a list of generic patterns.infoPer-page
Large inline SVG: when to move it to an external fileInline SVG cannot be cached separately from the HTML, so a big one is paid for on every page view. squirrel measures inline SVG size per page.infoPer-page
Lazy loading: how much of the page defers its loadA page-wide count of images and iframes using loading=lazy. squirrel reports the mix rather than judging individual images.infoPer-page
loading=lazy: which images need it and which must notImages below the fold that load eagerly compete with the ones the visitor can see. squirrel treats the first few images as above the fold.warningPer-page
Missing alt attribute: what an empty alt meansAn image with no alt attribute has no name for a screen reader. An empty alt is the correct way to say decorative, and squirrel accepts it.warningPer-page
Oversized image files: the 200KB and 1MB thresholdsOne unoptimised photo can outweigh every other asset on the page. squirrel measures the images the crawl fetched and reports the heavy ones.errorSite-wide
srcset: serving the right image size for the screenWithout srcset every visitor downloads the same file, sized for the largest screen. squirrel counts responsive images against fixed-size ones.infoPer-page
Thumbnails without srcset: small images serving large filesA 60 by 60 avatar that loads a 2000 pixel photo wastes almost all of it. squirrel reads each image’s real pixel size and flags small images that serve far more pixels than they display.warningPer-page
WebP and AVIF: converting from JPEG and PNGWebP and AVIF encode the same picture in far fewer bytes than JPEG or PNG. squirrel counts modern and legacy formats per page.infoPer-page

Key terms

  • Alt text: The alt attribute that gives an image a text alternative for screen readers, failed loads and search engines.
  • Broken link: A link whose target answers with an error, does not resolve, or is malformed.
  • Cumulative Layout Shift (CLS): A score for how much visible content moves unexpectedly while the page is in use; good is 0.1 or less.
  • HTTP status code: The three-digit code a server returns with every response; 2xx success, 3xx redirect, 4xx client error, 5xx server error.
  • Image width and height attributes: Declared width and height on <img> that let the browser reserve space before the file loads, preventing layout shift.
  • Lazy loading: Deferring off-screen images and iframes with loading=“lazy” so they load as the visitor scrolls.
  • Modern image formats: WebP and AVIF, which encode the same image in fewer bytes than JPEG or PNG.
  • Page weight: The total bytes a page downloads across HTML, CSS, JavaScript, images and fonts.
  • Responsive images: Serving differently sized image files with srcset, sizes and <picture> so each device downloads one that fits.
  • WCAG: The W3C’s Web Content Accessibility Guidelines, organised as testable success criteria at levels A, AA and AAA; 2.2 is current.

Performance covers the rest of page weight and the hero image’s loading hints. Accessibility checks the alt text on image buttons and embedded objects, and alt text that adds nothing, such as “photo of”. Links checks link targets, where Images checks image sources.

Learn more

Disable all Images rules

[rules]
disable = ["images/*"]

Type to search…

↑↓ navigate↵ openesc close