There are three different questions, and they must not be conflated:
The current “unused” label comes from questions 1 and 2, not question 3. That is why it is a cleanup candidate, not proof that no Drupal page can ever render the file.
usage.py)usage.py scans source files in the after-side theme (402 files in the current run):
[\w./%+@~-]+\.svg(?:\?[^\s'\";)#]+)?
?v=123.basename candidate.It does not search for partial stems such as files, class names such as .files, or arbitrary strings. A reference must end in .svg.
Example that is found:
background-image: url(../../images/icons/files.svg);
Example that is not found by this pass:
background-image: var(--admin-icon-files);
or a path assembled at runtime.
Known limits, also recorded in usage.json:
data:image/svg+xml URI (the filename disappears);Unmatched references are not treated as broken links; and a missing literal reference is not proof of non-use.
usage.py)For the icon audit I separately parsed --admin-icon-* definitions and var(--admin-icon-*) usages, including aliases such as:
--messages-icon: var(--admin-icon-info);
That produced the mode labels used in the gallery: mask, background, mask,background, image and unused. It is still static source analysis:
The alias step is currently analysis code, not part of the committed usage.py. That should be added before “unused” is treated as authoritative.
Run a browser against real Drupal pages and collect computed styles plus DOM/resource evidence, not source strings.
For every element and each of ::before, ::after, ::marker:
background-imagemask-image / -webkit-mask-imagecontent (it can contain a URL)list-style-imageborder-image-sourcecursorAlso collect:
<img src>, <object data>, <embed src><use href> and inline <svg>performance.getEntriesByType('resource')data:image/svg+xml values and hash them against the known SVG contentStates must be exercised explicitly:
Chromium DevTools Protocol CSS.forcePseudoState can force :hover, :focus, :active and :visited for computed-style collection. Pseudo-element styles are visible through getComputedStyle(element, '::after').
A minimal browser snippet:
const found = new Set();
function urls(value) {
for (const m of value.matchAll(/url\(["']?([^"')]+)["']?\)/g)) {
found.add(m[1]);
}
}
for (const el of document.querySelectorAll('*')) {
for (const pseudo of [null, '::before', '::after', '::marker']) {
const cs = getComputedStyle(el, pseudo);
for (const prop of [
'backgroundImage', 'maskImage', 'webkitMaskImage', 'content',
'listStyleImage', 'borderImageSource', 'cursor',
]) {
urls(cs[prop] || '');
}
}
}
for (const img of document.images) found.add(img.currentSrc || img.src);
for (const entry of performance.getEntriesByType('resource')) found.add(entry.name);
That output must then be mapped to theme paths, with data URIs hash-matched. Run it on a page/state manifest; a single page visit is not enough.
| Label | Evidence |
|---|---|
| Literal source reference | Exact path or basename candidate found in source |
| Alias source reference | A used var(--admin-icon-*) resolves to the asset |
| Rendered | Observed in computed styles/DOM/network in a recorded state |
| Not observed | Not seen in the pages/states covered so far |
| No source consumer found | No literal or alias reference in scanned source; still not proof about unexercised UI |
This is why the current cleanup is optional. If we want to delete a file with confidence, the rendered check must cover the relevant components and states first.