DEV Community

Masood Ahmad
Masood Ahmad

Posted on

A PNG Wearing a .webp Filename Cost My Services Page 441 KiB

The one optimization that moved the numbers on my Services page was rebuilding a single image — because the file was not what its name said it was.

PageSpeed flagged about 441 KiB of "improve image delivery" waste on that page in October. When I looked, the image was a 469 KB PNG wearing a ".webp" filename, and WordPress was still offering the big file to phones through srcset. So I converted it to a real WebP at quality 80 — 37.6 KB, 92% smaller — uploaded it as a new attachment, and removed the srcset so the old PNG could not be served again.

Measured on mobile PageSpeed, same tool and same slow-4G emulation: the page went from 72 to 85, and Largest Contentful Paint from 6.3 seconds to 3.5 seconds, with the image-delivery audit now passing. I am quoting the settled re-test after the caches rebuilt — one run a minute after purging read 58, which was a cold-cache artefact, and scores swing about ±10 between runs anyway.

I will not oversell it: 3.5 seconds is still above the 2.5-second "good" bar for LCP, and with no real traffic yet there is no field data, so this is a lab improvement, not a proven ranking gain. But it was the clearest lesson of the audit — check what the file actually is, not what it is called.

— Masood Ahmad, Editor, Dentist in Pico Rivera (dentalpicorivera.com)

Top comments (2)

Collapse
 
elias_0549e0e2ef8cf6ad89a profile image
RAMO •

"Check what the file actually is, not what it's called" is such a good takeaway. A quick file image.webp in a terminal, or looking at the response Content-Type in the Network tab, would have shown PNG right away, and it's an easy check to add before uploading anything.

The srcset detail is worth underlining too. Even after you fix the main file, WordPress keeps the old generated sizes around, so phones can still get the heavy version. Removing it works; regenerating thumbnails from the new real WebP would also bring the responsive sizes back without the PNG weight.

And thanks for being honest about the lab vs field data and the run-to-run swing. Most "I fixed LCP" posts skip that part.

Collapse
 
wu_ruihua_bbdb65cdbde7b48 profile image
wu ruihua •

Good catch, and it is more common than most teams think. Two things I would add, both from measuring the same failure mode.

1) The filename is not the only liar. Check the real bytes: a PNG starts with 89 50 4E 47, a JPEG with FF D8 FF, a WebP with 52 49 46 46 ... 57 45 42 50. Browsers sniff the actual type and ignore the extension, so the response header and the file signature are what matter. curl -sI on the asset URL and looking at Content-Type catches this in one command, and it is worth adding to CI as a check for every image under /wp-content/uploads.

2) Do not assume "convert to WebP" is always a win. For large photographic images it usually is, but the container overhead bites on small files: I have measured a 5.3 KB transparent PNG coming out of WebP at 6.1 KB, i.e. bigger. Same story with animated GIF to animated WebP on small frame counts. Rule of thumb from my tests: below roughly 100 KB, encode both and keep the smaller one instead of switching unconditionally.

The srcset point is the important one and it generalises: the old derivative stays reachable as long as any srcset or size variant still points at it, so the win only lands when the variant list is rebuilt too. Worth grepping the rendered HTML for the old file name afterwards - PageSpeed will re-flag it within a day if anything still serves it.