-
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-elements): remove resourceSize property #11733
Changes from 4 commits
d7811a4
adfd8c7
8e8183c
eaa77d1
2dd788f
cfe10e1
3981e89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ const FontSize = require('./seo/font-size.js'); | |
|
||
/* global window, getElementsInDocument, Image, getNodeDetails, ShadowRoot */ | ||
|
||
|
||
/** @param {Element} element */ | ||
/* istanbul ignore next */ | ||
function getClientRect(element) { | ||
|
@@ -77,7 +76,6 @@ function getHTMLImages(allElements) { | |
isCss: false, | ||
isPicture, | ||
loading: element.loading, | ||
resourceSize: 0, // this will get overwritten below | ||
usesObjectFit: ['cover', 'contain', 'scale-down', 'none'].includes( | ||
computedStyle.getPropertyValue('object-fit') | ||
), | ||
|
@@ -137,7 +135,6 @@ function getCSSImages(allElements) { | |
style.getPropertyValue('image-rendering') | ||
), | ||
usesSrcSetDensityDescriptor: false, | ||
resourceSize: 0, // this will get overwritten below | ||
// @ts-expect-error - getNodeDetails put into scope via stringification | ||
...getNodeDetails(element), | ||
}); | ||
|
@@ -332,13 +329,6 @@ class ImageElements extends Gatherer { | |
// Pull some of our information directly off the network record. | ||
const networkRecord = indexedNetworkRecords[element.src] || {}; | ||
element.mimeType = networkRecord.mimeType; | ||
// Resource size is almost always the right one to be using because of the below: | ||
// transferSize = resourceSize + headers.length | ||
// HOWEVER, there are some cases where an image is compressed again over the network and transfer size | ||
// is smaller (see https://github.com/GoogleChrome/lighthouse/pull/4968). | ||
// Use the min of the two numbers to be safe. | ||
const {resourceSize = 0, transferSize = 0} = networkRecord; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @patrickhulce this is still of concern ya? I'd expect this test to fail in this PR (but it isn't).. https://github.com/GoogleChrome/lighthouse/pull/4968/files#diff-b15e1d5e110701eeaa3cf353d4108a5e61e699ae3afbcdb272c7816b978784f1R137 (although it has since been modified 5674d61#diff-b15e1d5e110701eeaa3cf353d4108a5e61e699ae3afbcdb272c7816b978784f1 ). Seems this case was missed when that test was refactored. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we should still account for it in the optimization cases |
||
element.resourceSize = Math.min(resourceSize, transferSize); | ||
|
||
if (!element.isInShadowDOM && !element.isCss) { | ||
await this.fetchSourceRules(driver, element.devtoolsNodePath, element); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
changes like this make me unreasonably happy.