Skip to content

images/offscreen-lazy: top-of-page image reported below-fold after a few header icons #1250

Closed

Description

@deniskern

Summary

images/offscreen-lazy reports an image as "below-fold without lazy loading" although it is the first content image at the top of the page. It looks like the rule decides "below the fold" by image order (after a few small header icons) rather than by position.

Real case: a blog author header image rendered at y=127 px (viewport height 744 px) on a Shopify page is reported below-fold on every page of the template, so the site gets a fix advice (loading="lazy" on an above-fold image) that would hurt LCP.

Minimal repro

<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Image weight rule repro page for squirrel audits</title></head><body>
<header>
  ``&lt;img src="small.jpg" width="24" height="24" alt="Icon 1"&gt;&lt;img src="small.jpg" width="24" height="24" alt="Icon 2"&gt;``
  ````&lt;img src="small.jpg" width="24" height="24" alt="Icon 3"&gt;&lt;img src="small.jpg" width="24" height="24" alt="Icon 4"&gt;````
</header>
<main>`````&lt;img src="small.jpg" width="400" height="120" alt="Header image"&gt;`````<h1>Hero after icons</h1><p>Short intro.</p></main>
</body></html>
squirrel audit http://localhost:8766/hero.html --http -f json -o out.json

Actual

{"ruleId":"images/offscreen-lazy","status":"warn","message":"2 below-fold image(s) without lazy loading","items":[{"id":"small.jpg"}]}

Expected

No finding: all images sit within the first ~150 px of the page. Without layout (--http), small images with explicit width/height (icons, logos) should not count toward the "above-fold budget", or the rule should stay silent when it cannot tell, rather than recommend lazy loading for a top-of-page image. Control: the same page without the four icons yields no finding.

Version

squirrel 0.0.138 (macOS arm64), --http mode.

Triage

Confirmed against current main. packages/rules/src/images/offscreen-lazy.ts takes imagesArray.slice(opts.above_fold_count) as the below-fold set, so the split is purely by document order. Four small icons use up the default above-fold budget and the first real content image lands in the below-fold set.

Acceptance Criteria

  • The repro page above produces no images/offscreen-lazy finding in --http mode.
  • Small images with explicit width and height (icons, logos) do not consume the above-fold budget when there is no layout information.
  • A page with enough large content images before a late image still reports that late image as below-fold without lazy loading.
  • A regression test covers the icons-then-hero case, and the rule docs describe how the above-fold budget is counted.

Activity

  1. added
    bug
    size: S
    rules
    on Oct 29, 2026
  2. added theissue type on Oct 29, 2026
  3. nc9 commented on Oct 30, 2026

    @nc9
    Contributor

    Shipped in v0.0.143 (commits e54a36d). Checked every acceptance criterion against current main: the initial viewport is counted for content images, with tests.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrulessize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions