Technote

Development workflow Advanced

Series Images that do not slow the site down Part 8 of 8

Finding the files nothing in your site uses

The hard part is not deleting but proving nothing uses a file. Once you know where references hide, a safe order appears.

This is the last part of the series. We have chosen formats, set upload dimensions, tidied generated sizes, aligned responsive images and lazy loading, and covered vectors and video. Yet after a few years of operation, even with all those rules observed, files nothing references pile up: drafts, replaced banners, one-off material.

The hard part is proof, not deletion

Being confident that “nothing uses this file” is harder than it sounds, because references are scattered.

Where references live — the top two are easy to find, the rest are easy to miss

Images inserted into content are straightforward. The lower rows are the problem — especially URLs inside CSS and references a page builder has stored inside its own data structure, which ordinary searching rarely catches. Add one more case: files linked directly from a newsletter or another site. Nothing on your site uses them, but deleting them breaks somebody else’s screen.

A safe order — quarantine before you delete

Make the state reversible first — the observation window is the heart of this procedure

Back up first: the uploads folder together with the database, and if you can, restore it once to confirm. A backup you have never restored is not a backup.

Next, the candidate list. Whether by tooling or direct queries, assemble the set of files for which no reference was found. Treat it as a list of suspects, not a deletion list — the lower rows of the table above guarantee false positives.

So you quarantine. Move them to a separate folder rather than deleting, and watch the site for a few weeks. A missing image is conspicuous, and the server log records 404 requests for anything still being asked for. That observation window is the single most important step in the procedure. If nothing surfaces, then delete.

Rules that stop it accumulating again

Cleanup is never a one-off. To keep it from returning you have to adjust the habits. Do not upload review drafts to the media library — review them in the team’s own storage. When replacing an image, update the existing file rather than uploading a new one, so the URL survives and no orphan is left behind. And an agreed file naming convention means you can still tell what something is years later.

Closing the series

Across eight parts one point has held throughout: making images lighter is not the same as giving up quality. Choosing a format that matches the nature of the artwork, generating only the sizes you use, handing the browser accurate material to choose from, and treating exactly one first-screen image as the exception — all of those protect the design while reducing the weight. WordPress already ships responsive images and lazy loading by default. Our job is simply to give those defaults something correct to work with.

Wider performance topics continue in the performance archive, and the operational side of cleanup work in the development workflow archive. To overhaul the image pipeline, caching and server configuration as one job, there is our optimization program — and the order we work in, along with what we measure before and after, is published on the process page.

More on this topic

All technotes

Development workflow Practical

Turning taste arguments into rule checks

"It feels a bit cramped" can be neither argued with nor fixed. Spacing off the scale, colour off the palette, contrast below threshold, missing states — four rules…

Designers 9 min read

Development workflow Practical

Do not swap everything at once

A full swap makes every problem appear at the same moment — which means none of them can be attributed. So you switch one template at a time.

Designers 6 min read

Development workflow Practical

Adding an SCSS build, and whether to commit the output

WordPress themes are expected to deploy without a build step, which leads to the opposite conclusion from ordinary application code — and to its own costs.

Developers 7 min read

₩270,000 · Join the program