When loading images on my site, firefox briefly (for around half a second) flashes the alt text before the image loads.
There are other issues about this, but everyone suggests adding
img:-moz-loading {
visibility: hidden;
}
I have done so in the top-level CSS for the site, and it seemed to work in the past but has regressed. The alt text still flashes, and I can’t find any alternative paths forward. There is a closed Bugzilla report without any activity in the past 5 years.
Any idea on how to dig deeper into this? From what I can tell the img
element has nothing non-standard going on.
2
Answers
I assume that you have some kind of lazy loader.
So you can hide
alt
untilimg
hassrc
like this:You can set transparent text color on the image:
It seems to do the job in Firefox 123. Below is the filmstrip view of the page load generated by webpagetest.org:
The test was done on Firefox nightly on a fast 3G network. All four images have
alt
,width
,height
andbackground-color
set.The top two images do not have any CSS while the bottom two images have
color: transparent
.The top two images display the alternate text until the image starts rendering. The bottom two images do not display the alternate text at all.
As for
:-moz-loading
, the documentation says that:The description of "in the process of loading" is not provided but we can assume that the process starts as soon as the image is "queued" for downloading.