filter · Image filters
Deduplicate inlined images (dedup_inlined_images)
- Category:
- Image
- CoreFilters:
- No
- OptimizeForBandwidth:
- No
- Risk:
- Generally safe
dedup_inlined_images replaces repeated inline data: URIs on the same page with JavaScript references to the first occurrence, reducing HTML size.
How it works
dedup_inlined_images shrinks pages that repeat the same inlined image. When two or more references have become identical data: URIs, the first occurrence keeps its bytes and gets an id; every later occurrence of the same data URI loses its src and instead carries a one-line inline script that copies the first image’s src back onto the element at run time. There is a floor below which dedup does not pay: a data URI must be longer than 185 bytes, roughly the size of the restoring snippet, or it is left as it is. The filter needs JavaScript, so it is disabled for user agents that cannot lazy-load images and for XMLHttpRequests, and it stands down inside <noscript> or when the page’s Content-Security-Policy forbids inline scripts. The num_dedup_inlined_images_candidates_found and num_dedup_inlined_images_candidates_replaced statistics in the admin console show how much it found and how much it replaced.
When to use it
- Not in CoreFilters: it runs only when you enable it by name.
- Risk rating on these docs: Generally safe.
Risks
- Inlining increases HTML size. Inlined images are not cached separately by the browser. Set
ImageInlineMaxBytesconservatively.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters dedup_inlined_imagesnginx
pagespeed EnableFilters dedup_inlined_images;IIS (pagespeed.config)
pagespeed EnableFilters dedup_inlined_images| Parameter | Default | Description |
|---|---|---|
ImageInlineMaxBytes | 3072 | Maximum image size in bytes to inline as a data: URI |
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Live example
Replaces repeated inlined images with a reference to the first copy.
Measured on the demo page, original against optimized:
-
HTML size
982 B → 901 B −8%
Frequently asked questions
- What does the dedup_inlined_images filter do?
dedup_inlined_imagesreplaces repeated inlinedata:URIs on the same page with JavaScript references to the first occurrence, reducing HTML size.- Is dedup_inlined_images enabled by default?
- No.
dedup_inlined_imagesis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable dedup_inlined_images on Apache and nginx?
- Add
ModPagespeedEnableFilters dedup_inlined_imageson Apache orpagespeed EnableFilters dedup_inlined_images;on nginx. On IIS, addpagespeed EnableFilters dedup_inlined_imagesto pagespeed.config.
Related filters
- inline_images — Inline images
- inline_preview_images — Inline preview images
- resize_mobile_images — Resize images for mobile
- convert_gif_to_png — Convert GIF to PNG
- convert_jpeg_to_avif — Convert JPEG to AVIF
- convert_jpeg_to_progressive — Progressive JPEG
- convert_jpeg_to_webp — Convert JPEG to WebP
- convert_png_to_jpeg — Convert PNG to JPEG
This page is drawn from the dedup_inlined_images entry on Image filters. Every filter in one table: PageSpeed filters.