Minimum viable no-image image src

December 26th, 2023. Tagged: images, performance

Remember spacer.gif? Yeah, "good" old days...

We may now have all the CSS features to make everything better but sometimes the ghost of spacer gif rears its transparent head. And that's an HTTP request. A request that's better devoted to something useful. Like an LCP image or something, I dunno.

So anyway, sometimes a simple change is not that simple and things need to happen gradually. So here's the first line of defence. Replace the spacer's src with a tiny little data URL. A minimum-viable src that doesn't make a request and doesn't break the app.

data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>

As in

<img 
  src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>" 
  ...
>

Demo:

The best request is the one never made, amiright?

Tell your friends about this post on Facebook and Twitter

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov