ausi/respimagelint

Overly-verbose results when image has zero width

eeeps opened this issue · 5 comments

eeeps commented

Ran the bookmarklet on a page with an image whose initial state was display: none today. Hoo boy.

Here's a reduced test case: https://codepen.io/eeeps/pen/YJKPew

And the results:

screen shot 2018-09-26 at 2 49 24 pm

eeeps commented

I wonder if the output here should be "Try using sizes="0px"", or if the bookmarklet can be even smarter about display: none’d images than that (skip them?).

ausi commented

I think the specific rule that checks the sizes attribute should ignore display:none images.

But maybe we should add a new rule that checks for display:none?
Something like “The image seems to be hidden. It should be removed from the webpage to reduce bandwidth.”.

eeeps commented

Sounds good to me. There are good use cases for having the image preloaded but initially invisible -- but most of the time, best practice is going to be to lazy-load it when whatever event that makes it visible happens.

Here's an example of an image hidden <768px:

image

However, once I added sizes="(min-width: 2540px) 2400px, (min-width: 780px) calc(93.1vw + 54px), 100vw", the linter no longer complained.

ausi commented

Fixed the overly verbose suggestion in 51ecc89

I keep this issue open for the feature to report warnings for display:none images in general.