squirrelscan
GitHub

Oversized image files: the 200KB and 1MB thresholds

One unoptimised photo can outweigh every other asset on the page. squirrel measures the images the crawl fetched and reports the heavy ones.

What an oversized image is

Images are usually the largest thing a page downloads. A camera JPEG straight out of a phone is several megabytes; the same picture, resized to the width it is displayed at and encoded as WebP, is often under 100 KB with no visible difference.

Weight shows up directly in Largest Contentful Paint, because the LCP element is an image on most content pages, and it costs the visitor real bandwidth. squirrel’s default thresholds are 200 KB for a warning and 1 MB for a failure.

What squirrel checks

The rule is site-wide and reads the image sizes the crawl fetched. It emits up to two checks:

  • Pass when the crawl recorded no image resources at all. Message: No image files detected. A recorded resource whose size could not be read falls through to the pass below instead.
  • image-file-size fails for files above error_bytes, 1 MB by default. Message: 2 image(s) exceed 1.0 MB, each listed with its URL, size, status and content type, and the pages it appears on. Severity error, weight 7.
  • image-file-size-warn warns for files above warn_bytes and at or below the error threshold. Message: 9 image(s) exceed 200.0 KB.
  • image-file-size passes when neither fired. Message: All image files are within size limits.

Only images the crawl actually fetched are measured, so an image loaded by script after render does not appear.

How to fix it

cwebp -q 80 photo.jpg -o photo.webp

Resize to the largest dimension the image is displayed at, then encode as WebP or AVIF at a quality around 75 to 85. An image CDN does both on request, which is usually less work than a build step.

Serving several sizes with srcset is what stops a phone downloading the desktop file. Compression alone does not fix that.

Rule IDimages/image-file-size
CategoryImages
ScopeSite-wide
Severityerror
Weight7/10

Options

OptionTypeDefaultDescription
warn_bytesnumber204800Byte size to trigger warning
error_bytesnumber1048576Byte size to trigger error

Configuration example

[rule_options."images/image-file-size"]
warn_bytes = 102400
error_bytes = 512000

Enable / disable

Disable this rule

[rules]
disable = ["images/image-file-size"]

Disable all Images rules

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

Enable only this rule

[rules]
enable = ["images/image-file-size"]

enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.

Images findings ship in every audit next to the SEO, performance and agent experience rules. See Core Web Vitals for how an agent works through a report.

References

Check your site

Run squirrel audit https://example.com and open the Images section of the report. Every oversized image is listed with its size and the pages it appears on. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.

Type to search…

↑↓ navigate↵ openesc close