uses-responsive-images only cares about savings not about correct use of responsive images
See original GitHub issueThe uses-responsive-images
check only checks whether a too large image is used. This means that it only catches cases in which the used image is way bigger than the actual display size. This typically happens when developers just shove a @2x or larger version of the image without using a srcset
.
The part that is missing is when the image is too small compared to the display size. I.e, no @2x version is in use.
Basically I’m suggesting to add something along the lines:
const DPR = artifacts.ViewportDimensions.devicePixelRatio;
const TOLERANCE = 0.9; // This is to not produce that many violations, I'd like it to be set to 1.
const bigEnough = image.displayedHeight <= image.naturalHeight / (DPR * TOLERANCE) && image.displayedWidth <= image.naturalWidth / (DPR * TOLERANCE);
I understand, that doing in that way may change the scope of the audit, as it is currently part of the byte efficiency category. So feel free to recategorize this as a feature request.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Responsive images - Learn web development | MDN
In this article, we'll learn about the concept of responsive images — images that work well on devices with widely differing screen sizes, ......
Read more >Responsive Images - A Reference Guide from A to Z
A complete guide about responsive images, why we need it, latest responsive image techniques with code samples.
Read more >Responsive images - web.dev
Responsive web design means that not only can our layouts change based on device characteristics, but content can change as well. For example, ......
Read more >Properly size images - Chrome Developers
The main strategy for serving appropriately sized images is called "responsive images". With responsive images, you generate multiple versions ...
Read more >How to have responsive images in Wordpress - Novo-Media
But even if your images have been well compressed, this does not mean that the browser displays the right image according to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@patrickhulce below is the new audit proposal questionnaire, let me know if you need something else.
Provide a basic description of the audit
The audit, called for now
ImagesHaveRightSize
, will enforce that source images in a website are at least larger to how they are displayed. This is necessary to ensure that images look crisp to the user.Note that for technical reasons, similar to the ones given in the audit
UsesResponsiveImages
, the audit will not consider css images.How would the audit appear in the report?
The audit would appear in the
Best Practices
category.For a failing test the results would be similar to those of
UsesResponsiveImages
.It would be a tabular data showing the offending images, with a thumbnail, the image’s original size and the dispalyed size.
How is this audit different from existing ones?
This is a complement to
UsesResponsiveImages
, which only checks whether the images are small enough. This check will also enforce that the images are not too small. Effectively requiring the users to use responsive images to pass the audit. This also complements the auditImeageAspectRatio
.What % of developers/pages will this impact?
I’d say that more than 90% of sites will be impacted by ths audit. I executed the POC (shown at the end), and all of the top 10 Alexa sites were affected, although some use techniques to replace the images with a higher density version after scrolling them into view.
Tht number is also supported by some work I did while at Google, in which I developed an extension to detect incorrectly sized images. From what I remember at the time, all the Google sites I tried were affected by it. Note though, that that check was considering css images as well.
How is the new audit making a better web for end users?
This would make a better web for users as nowadays most devices have a high density display, the so called Retina displays. For example on Android, more than 90% of the devices have a pixel density greater than one. See https://developer.android.com/about/dashboards. On iOS and MacOs, all of their devices have a high density. Even Chromebooks have retina displays. And now with the adoption of 4k or even 8k monitors, more and more users have access to a high resolution display. This audit would also prevent
What is the resourcing situation?
The audit is quite similar to
UsesResponsiveImages
, so I could volunteer an initial PR with the change. Regarding the documentation, it probably should be a merge between the articles https://web.dev/image-aspect-ratio/ and https://web.dev/uses-responsive-images/, but I have no idea how to edit or contribute to that site. Regarding the audit’s maintainance, I’d imagin thate someone from the Lighthouse team needs to champion it.Any other links or documentation that we should check out?
A proof of concept that can be used to test a website via the JS console is attached.
Page adapted 😃 I have put an svg image instead of the png image, I feel better now ! I hope the image will look better on your mac book pro. As it is a pwa you may have to load 2 new games before seeing the change.
There is only the “learn more” link to fix.
Thank you for your work and your help.