Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

images

Rules: 11

images/compression

An image can be re-encoded much smaller in its own format

images/compression/weak · warning · score 4.8 · site

Unoptimised images make pages heavier than they need to be, so visitors on slow connections wait longer. Only images where a re-encode saves a meaningful share are flagged.

Fix

Re-encode the image with a modern tool at a lower quality or smaller dimensions.

Runs by default, in the recommended ruleset.

References

For rule authors

Reads

  • resources.images

images/dimensions

Images lack width and height attributes

images/dimensions/missing · warning · score 5.4 · page

Without them the browser cannot reserve space, so the page jumps as each image loads and visitors lose their place while reading. It also hurts the Cumulative Layout Shift score search engines read.

Fix

Add width and height attributes to each <img>.

Runs by default, in the recommended ruleset.

References

For rule authors

Reads

  • html.images

images/font-display

Web fonts hide text while they load

images/font-display/missing · warning · score 5.0 · site

An @font-face without font-display: swap, fallback or optional leaves text invisible until the font arrives, so visitors on slow connections stare at a blank page.

Fix

Add font-display: swap (or fallback or optional) to each @font-face.

Off by default; a group that runs images:assets turns it on.

References

For rule authors

Reads

  • resources.text

images/font-format

A web font is served in a format other than WOFF2

images/font-format/outdated · warning · score 4.4 · site

WOFF2 compresses fonts best and every current browser supports it, so other formats make visitors download more for the same text.

Fix

Convert the font to WOFF2.

Off by default; a group that runs images:assets turns it on.

References

For rule authors

Reads

  • resources.fonts

images/format

A JPEG, PNG or GIF image would be smaller as WebP or AVIF

images/format/outdated · warning · score 5.2 · site

Old image formats cost visitors extra bytes on every page view, which slows loading on mobile connections. Only images where a re-encode saves a meaningful share are flagged.

Fix

Convert the image to WebP or AVIF.

Runs by default, in the recommended ruleset.

References

For rule authors

Reads

  • resources.images

images/lazy-loading

Images below the fold are not lazy-loaded

images/lazy-loading/missing · warning · score 4.8 · page

Images the visitor has not scrolled to still download up front and compete with the content they came to read. Only pages rendered in a browser are judged.

Fix

Add loading=lazy to off-screen images.

Off by default; a group that runs images:live turns it on.

References

For rule authors

Reads

  • imageLayout

Images in the first viewport are lazy-loaded

images/lazy-loading/slow · warning · score 5.8 · page

A lazy image visible on arrival starts loading late, which delays the largest content and makes the page feel slow. Only pages rendered in a browser are judged.

Fix

Remove loading=lazy from images in the first viewport.

Off by default; a group that runs images:live turns it on.

References

For rule authors

Reads

  • imageLayout

images/minification

A stylesheet or script is served without minification

images/minification/missing · warning · score 4.2 · site

Whitespace and long names in CSS and JavaScript add bytes that every visitor downloads before the page can render. Only files where minifying saves a meaningful share are flagged.

Fix

Minify the stylesheet or script in the build.

Off by default; a group that runs images:assets turns it on.

References

For rule authors

Reads

  • resources.text

images/rendered-size

Images ship far more pixels than the page renders

images/rendered-size/large · warning · score 4.4 · page

An image much wider than its box wastes bandwidth and slows loading, especially on phones. Vector images are exempt, and only pages rendered in a browser are judged.

Fix

Serve an image whose natural width matches what the layout renders.

Off by default; a group that runs images:live turns it on.

References

For rule authors

Reads

  • imageLayout
  • resources.images

images/srcset

Images without srcset are far wider than they display

images/srcset/large · warning · score 4.6 · page

A single large file is sent to every screen, so phones download pixels they never show. Only images with a numeric width attribute and no srcset are compared.

Fix

Serve a srcset with a width matching what the page renders.

Runs by default, in the recommended ruleset.

References

For rule authors

Reads

  • html.images
  • resources.images

images/weight

An image is heavier than the weight limit

images/weight/large · warning · score 5.6 · site

A very large image file slows the page for every visitor and eats mobile data. The limit is a setting, 200 kB by default.

Fix

Resize or re-compress the image so the file is below the weight limit.

Runs by default, in the recommended ruleset.

References

For rule authors

Reads

  • resources.images