-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new_audit: check images are big enough #10460
new_audit: check images are big enough #10460
Conversation
New audit checking images are big enough. This is a complement to UsesResponsiveImages. Fixes GoogleChrome#10434.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great @sk- thanks for pumping this out so quickly!
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
I vaguely recall there being discussion in the past about this kind of audit and there being issues with a lot of use cases where high DPI images don't exist (old assets or whatever), aren't needed (smaller asset scales fine enough and it saves bytes), or aren't used on purpose (beyond just lazy loading...graphical effects or whatever). (edit: the first case is probably fine to fail, I guess, even if the site can't fix them) I could see us launching and then gradually adding exceptions to the audit, but there may be a lot of users upset over failing an audit in Best Practices in the meantime :) Maybe we need to collect some data on how a decent sample of sites will fare on this audit? |
…prevent contradictions with the advice given for offscreen images
@brendankenny it'd be great if you can find a link to that conversation. With regard to point number 2) ( The only case I know in which an asset with a lower pixel density scales well is when you want it to be pixelated and you specify: image-rendering: pixelated;
image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges; Point number 3 is also strange in mi opinion, as right now there are many audits that developers may decide to not address on purpose (for example the I guess we could change the weight of the audit, if the score is what ultimately annoys people. With the current settings, the audit is not reporting that many offending images. For example for the top 10 US site according to Alexa, the results are the following:
Note also, that the values provided are up for discussion and tweaking. |
@patrickhulce document.querySelector('image').naturalWidth However, on the gatherer I see that there's some code to compute the natural size for some images (https://github.com/GoogleChrome/lighthouse/blob/abee0c0/lighthouse-core/gather/gatherers/image-elements.js#L213-L223). Should we include in that check images in which So I guess, we would need to add a field We may also want to add another field called image-rendering: pixelated;
image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges; Let me know WDYT, I'm open to suggestions. |
Sorry, can't find anything in chat or email. It was probably back when
The tension is that users really don't like when Lighthouse asks them to fix something they think is a legitimate technique. Even unscored things come across as criticism/instructions from Google to fix something. That doesn't mean we shouldn't do it, but it is a cost that has to be weighed against the benefit of an audit. |
Yeah
I think the safeguard of passing
Yeah SGTM too! Good catch 👍 |
Great, will then add those 2 properties in 2 PRs first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % nits
thanks again @sk-!
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
…sk-/lighthouse into new_audit_image_size_responsive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still LGTM!
@patrickhulce I added the requested smoke test, let me know if everything looks fine. I am now skipping all images with a density descriptor, as there is no way to get the actual size, and I did not want to reload them, as that could break some of the assumptions about The only missing thing that may be a little annoying is the fact that if an image has wrong aspect ratio and is at the same time too small, it will reported in both categories. The problem of fixing that is that it would require pretty much the same logic present in the Is there a list of websites that you would like me to test the audit. From the list I posted earlier, the only change is that now wikipedia is passing. |
Summary
New audit checking visible images are big enough. This is a complement to
UsesResponsiveImages
.Related Issues/PRs
Fixes #10434. Check that issue for the New Audit Proposal.