Skip to content
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

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

patrickhulce
Copy link
Collaborator

@@ -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);
Copy link
Member

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?)

Copy link
Collaborator Author

@patrickhulce patrickhulce Apr 14, 2018

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 😆

@brendankenny
Copy link
Member

looks like these tests might be helped by #4988?

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@patrickhulce patrickhulce merged commit 06a0a45 into master Apr 19, 2018
@patrickhulce patrickhulce deleted the image_resource_size_fix branch April 19, 2018 16:12
kdzwinel pushed a commit to kdzwinel/lighthouse that referenced this pull request Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants