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(legacy-javascript): make opportunity #10881

Merged
merged 42 commits into from Jul 10, 2020
Merged

core(legacy-javascript): make opportunity #10881

merged 42 commits into from Jul 10, 2020

Conversation

connorjclark
Copy link
Collaborator

Related: #10369

@patrickhulce
Copy link
Collaborator

I'll take a closer look at this tomorrow @connorjclark I promise :)

@GoogleChrome GoogleChrome deleted a comment from tojin12341za Jun 3, 2020
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

I think this is great! I love the graph direction and would love to see it included in the test of legacy-js to make sure it doesn't fall out of sync. I can imagine us forgetting to update it in the future if we don't

estimatedWastedBytesFromPolyfills += [...modulesSeen].reduce((acc, module) => {
return acc + graph.moduleSizes[module];
}, 0);
// Not needed?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah maybe just add a test for this rather than an extra min?

{key: null, itemType: 'code', subRows: {key: 'signals'}, text: ''},
{key: 'url', valueType: 'url', subRows: {key: 'locations', valueType: 'source-location'}, label: str_(i18n.UIStrings.columnURL)},
{key: null, valueType: 'code', subRows: {key: 'signals'}, label: ''},
{key: 'wastedBytes', valueType: 'bytes', granularity: 0.05, label: str_(i18n.UIStrings.columnWastedBytes)},
Copy link
Collaborator

Choose a reason for hiding this comment

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

love the additional actionability of this 👍

…-estimation.js

Co-authored-by: Patrick Hulce <patrick.hulce@gmail.com>
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

flushing for now but didn't realize how much had changed since last review, i'll update the label and take a look tomorrow

* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
* @param {LH.Crdp.Network.ResourceType=} resourceType
*/
static async estimateTransferRatio(transferRatioByUrl, url, artifacts,
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah nice catch! +1 to sharing this piece between the two

I will say though that this has an unusual API compared to its surroundings to live as a utility like this (cache state that you keep outside of this method but this staticish method also updates it?). also seems overly specific to scripts and not stylesheet content, HTML, etc?

If we want to land this quickly I think I'd prefer to just leave it on duplicated-javascript and have legacy-javascript.js pull it in so other audits don't get the idea that it's generic and ready to roll. a name like estimateTransferRatioForScript might help too 👍

how do you feel about that?

* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
* @param {LH.Crdp.Network.ResourceType=} resourceType
*/
static async estimateTransferRatio(transferRatioByUrl, url, artifacts,
Copy link
Collaborator

Choose a reason for hiding this comment

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

also kinda weird that duplicated-javascript only really cares about the transfer size ultimately, so maybe a future refactor could augment that helper with some script ability instead of this new one?

const script = artifacts.ScriptElements.find(script => script.src === url);

if (!script || script.content === null) {
// Can't find content, so just use 1.
Copy link
Collaborator

Choose a reason for hiding this comment

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

now that I'm looking at it with fresh eyes this feels wrong, should probably do something like borrowing ratio from the main resource or something that estimateTransferSize does

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

few naming q's and the location of estimate transfer ratio up for debate but other than that looks good

estimatedWastedBytesFromTransforms += pattern.estimator(result);
}

const estimatedWastedBytes =
Copy link
Collaborator

Choose a reason for hiding this comment

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

love the explicitness here 👍

Co-authored-by: Patrick Hulce <patrick.hulce@gmail.com>
@patrickhulce
Copy link
Collaborator

FYI @connorjclark I think you have a few conflicts to resolve before this lands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants