Minimum viable no-image image src

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 […]


This content originally appeared on phpied.com and was authored by Stoyan

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?


This content originally appeared on phpied.com and was authored by Stoyan


Print Share Comment Cite Upload Translate Updates
APA

Stoyan | Sciencx (2023-12-26T21:30:44+00:00) Minimum viable no-image image src. Retrieved from https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/

MLA
" » Minimum viable no-image image src." Stoyan | Sciencx - Tuesday December 26, 2023, https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/
HARVARD
Stoyan | Sciencx Tuesday December 26, 2023 » Minimum viable no-image image src., viewed ,<https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/>
VANCOUVER
Stoyan | Sciencx - » Minimum viable no-image image src. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/
CHICAGO
" » Minimum viable no-image image src." Stoyan | Sciencx - Accessed . https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/
IEEE
" » Minimum viable no-image image src." Stoyan | Sciencx [Online]. Available: https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/. [Accessed: ]
rf:citation
» Minimum viable no-image image src | Stoyan | Sciencx | https://www.scien.cx/2023/12/26/minimum-viable-no-image-image-src/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.