-
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
core(image-usage): use min of resourceSize/transferSize #4968
Conversation
@@ -79,14 +79,15 @@ class OptimizedImages extends Gatherer { | |||
const isSameOrigin = URL.originsMatch(pageUrl, record._url); | |||
const isBase64DataUri = /^data:.{2,40}base64\s*,/.test(record._url); | |||
|
|||
if (isOptimizableImage && record._resourceSize > MINIMUM_IMAGE_SIZE) { | |||
const actualResourceSize = Math.min(record._resourceSize, record._transferSize); |
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.
can _transferSize
be larger than _resourceSize
? Seems possible, especially with image data, but even in that case wouldn't we still want to use the transfer size because they're sending too many bytes (it's just in that case one of the culprits is a bad choice to gzip?)
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.
in every case I've seen with my own two 👀 for images transferSize = resourceSize + size of headers
, highly irregular to try to gzip/brotli/etc an image since images are always compressed with their own domain-specific method that is way more effective, but apparently the tweet ran into that case with a 30MB image 😆
looks like these tests might be helped by #4988? |
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
should fix https://twitter.com/dougsillars/status/984786614156189697