From 97cb3b91bf23d470ecb907530fe09034d3b87749 Mon Sep 17 00:00:00 2001 From: Jan Sroka Date: Wed, 8 Jul 2026 22:32:01 +0200 Subject: [PATCH] docs(memory): note how to detect unused assets + srcset/URL-encoding traps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Captures the reusable method for checking whether an image/PDF/CSS class is really unused (grep the built _site including .webmanifest, not just source) and the two false-positive traps hit this session: srcset responsive variants (the 2 MB hero original never ships — only its -p-* variants) and URL-encoded filenames (PDFs with %20). Also records the maintainer's decision not to delete orphaned images. Co-Authored-By: Claude Opus 4.8 (1M context) --- memory/README.md | 1 + memory/finding-unused-assets.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 memory/finding-unused-assets.md diff --git a/memory/README.md b/memory/README.md index 1bdf1dd..5dd9c16 100644 --- a/memory/README.md +++ b/memory/README.md @@ -8,3 +8,4 @@ and link them below. - [ci-and-verification.md](ci-and-verification.md) — how the site builds/deploys and how to verify changes (incl. the rtk/prettier gotcha) - [csp-policy.md](csp-policy.md) — the meta-tag CSP: what it allows and why, and what can't be enforced this way - [seo-and-metadata.md](seo-and-metadata.md) — SEO/metadata decisions (German-only, no JSON-LD, canonical/feed) +- [finding-unused-assets.md](finding-unused-assets.md) — how to check if an image/PDF/CSS class is really unused (and the srcset / URL-encoding traps) diff --git a/memory/finding-unused-assets.md b/memory/finding-unused-assets.md new file mode 100644 index 0000000..15f9c20 --- /dev/null +++ b/memory/finding-unused-assets.md @@ -0,0 +1,25 @@ +# Finding unused assets (images, PDFs, CSS classes) + +This is a Webflow export, so `assets/` carries a lot of dead scaffolding. When checking whether an asset is really unused, grep the **built `_site`** (the +ground truth of what ships), not just the source — and scan HTML **plus CSS plus `site.webmanifest`**, because references live in all three. + +```bash +bundle exec jekyll build >/dev/null +grep -rhoE '[A-Za-z0-9._%ÖÄÜ+-]+\.(png|jpg|jpeg|svg|webp|gif)' _site \ + --include='*.html' --include='*.css' --include='*.webmanifest' | sort -u +``` + +Two false-positive traps that made me nearly flag _used_ files as orphans: + +- **`srcset` responsive variants.** Webflow images come as `foo.png` plus `foo-p-500.png` / `-p-800` / `-p-1080`. Pages reference the variants via `srcset`, + often NOT the full-size original. (Real case: the index hero uses only the `InOEG_IRIS-One-Pager_Hero-p-*` variants; the 2 MB full-size + `InOEG_IRIS-One-Pager_Hero.png` is never referenced and never ships. So the earlier "optimise the 2 MB hero" idea was moot — PurgeCSS/the build already never + emit it.) +- **URL-encoded filenames.** PDFs/images with spaces are linked with `%20` (e.g. `230829_inoeg_Halbzeit Ampel.pdf` → + `/documents/230829_inoeg_Halbzeit%20Ampel.pdf`). A plain `grep -F "Halbzeit Ampel.pdf"` misses the link. Cross-check by counting: `` vs + `` — all 13 documents/ PDFs are in fact linked in `veroeffentlichungen.md`. + +Also note: dead Webflow CSS (unused `w-icon-*`, `w-lightbox-*` rules and their embedded `data:` fonts/images) is stripped from production by PurgeCSS, so it +never reaches users even when left in the source `assets/css/`. + +Decision on file (2026-07): the maintainer chose NOT to delete orphaned image files despite ~4 MB being unused. Don't propose asset deletion again unless asked.