Image Optimization (image-optimization)
Summary
Image sizing, formats, lazy loading, and alt text via HTTP, and the pictures each device downloads and shows (phone and desktop, in a browser).
Classification
- Category:
PERFORMANCE - Plugin id:
image-optimization - Version:
1.2.0 - Target types:
WEBSITE,WEBSHOP - Weight class:
MEDIUM - Risk level: not set on plugin object
- Browser required: Optional — the HTTP checks need none; the device phase runs when a browser is available (local Chromium or a kaduno-render session)
- Tier / group: Tier 1 — HTTP-only, with a browser phase
Schedule
- scheduleHints:
{ defaultInterval: '0 6 * * 1', priority: 7 } - Prerequisites: None declared on this plugin.
Configurable inputs
Public keys are derived from inputSchema: z.object({ ... }) (underscore-prefixed keys are runtime-only and omitted here).
| Field | Notes |
|---|---|
timeout |
Zod field in inputSchema — see source for defaults, min/max, and .describe(). |
maxImages |
Zod field in inputSchema — see source for defaults, min/max, and .describe(). |
oversizeThresholdKB |
Zod field in inputSchema — see source for defaults, min/max, and .describe(). |
crawlDelay |
Zod field in inputSchema — see source for defaults, min/max, and .describe(). |
Runtime / injected config
- Prior throttle metrics may be injected for adaptive politeness.
What it does
- Runs as part of the worker test execution pipeline; results become
Runrows and may createFindingrecords. - The HTTP checks: each
<img>of the page HTML is sized with one request; findingsimg-oversize:,img-legacy-format:,img-no-lazy:,img-no-alt:. - The device phase, below: the target URL opened as a phone and as a desktop.
Device phase (TESTE-NO-542)
After the HTTP checks the target URL is opened twice in a browser, each in its own page, without scrolling:
| Device | Viewport | DPR | Emulation |
|---|---|---|---|
phone |
390 × 844 | 3 | mobile viewport, touch |
desktop |
1440 × 900 | 2 | none |
Both carry the TesteBot user agent. This is the teste.no half of Kaduno's image budget (K-SHOP-6718); Kaduno's Site Health reads the result (K-SHOP-6727). The devices and definitions are the same as Kaduno's own measurement.
Per picture and device (pictures[])
| Field | Meaning |
|---|---|
page |
The page measured (the target URL) |
device |
phone or desktop |
url |
The picture's URL as the browser chose it (currentSrc), absolute and otherwise verbatim — Kaduno maps /assets/ paths back to CMS blocks |
bytes |
Resource Timing transferSize, else encodedBodySize; where that is 0 (a cross-origin file without Timing-Allow-Origin, most CDNs) the size the network reported for the request |
servedWidth |
The ?w= rung of the URL, else the file's own width (naturalWidth, corrected for a 2x / 640w descriptor) |
renderedWidth |
The <img> box width in CSS px; 0 without a box |
ratio |
servedWidth ÷ (renderedWidth × DPR), two decimals; 1 is exact, 2 is twice too wide; 0 without a box |
aboveFold |
The box starts within the viewport height before scrolling |
hiddenDownload |
The file was downloaded and no <img> that uses it has a box (a theme that ships a phone and a desktop picture and hides one with CSS) |
wrongDevice |
A candidate of a <picture> other than the chosen one was downloaded and no <img> uses it (a preload without the <source>'s media query). Listed as its own entry under its own URL |
A picture shown several times is one entry (its widest box; above the fold when any box is). A picture the browser never fetched (a lazy one below the fold) is not listed. fold: { phoneBytes, desktopBytes } is the sum of bytes of the aboveFold pictures per device.
Where the numbers go
- Artifact
pictures.json:{ schemaVersion: 1, pictures, fold, measuredAt, devices }. Written only when both devices were measured, so it is never half a measurement.schemaVersion(IMAGE_PICTURES_SCHEMA_VERSIONin@teste-no/shared) is the contract's version, also in the Sites API answer; a document stored before it existed reads as 1. A consumer that gets a version it does not know treats the answer as unreadable and skips it, never guessing. - Metrics:
devicePhase(measured/partial/not_measured/browser_unavailable),devicePhasePhone,devicePhaseDesktop(measured,timeout,load_failed,http_error,error,no_time),fold_phone_bytes,fold_desktop_bytes,hidden_downloads,wrong_device_fetches,worst_ratio_phone,worst_ratio_desktop. A device that was not measured hasnull, never 0. - Sites API:
GET /api/sites/:system/:externalId/imagesreturns the latest complete measurement (seedocs/api-reference.md).
Findings
WARNING, at most 20 of a kind per device (the artifact carries all):
image-optimization:hidden-download:<device>:<page>:<image URL>— a picture downloaded and never shown.image-optimization:wrong-device:<device>:<page>:<image URL>— a picture fetched for the other device.
The fingerprint holds the URL verbatim, so a picture keeps its finding from run to run; only a URL over 600 characters is cut, with a hash of the whole.
What it does not judge
The ratio and byte budgets (ratio ≤ 2.0, single picture and fold bytes per device) are the store's image_budget_* settings in Kaduno, and Kaduno files those findings. teste.no reports the numbers and raises no ratio or byte finding from the device phase.
When a device is not measured
- The HTTP result is kept. The run states its coverage (TESTE-NO-512): the HTTP prefixes plus the prefixes of the devices that were measured, so the findings of a device that timed out or would not open stay as they were.
- Without a browser,
devicePhaseisbrowser_unavailableand only the HTTP checks ran. - A page with no
<img>in its HTML is measured by the devices when it shows pictures after rendering. With none on either device the test does not apply (skipped, not applicable); when a device would not open it is a plain skip, which closes nothing. - The run given up (hard timeout, browser service gone) ends the run and is never a result.
Limits of this step
Only the target URL is measured per device; the pages of "Run on other pages" get the HTTP checks only.
Source
packages/test-plugins/src/plugins/image-optimization.tspackages/test-plugins/src/image-device-measure.ts(the browser half)packages/shared/src/utils/image-device-pictures.ts(the rules and the contract schema)