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: surface LCP element in a diagnostic audit #10517

Merged
merged 45 commits into from
May 1, 2020
Merged

core: surface LCP element in a diagnostic audit #10517

merged 45 commits into from
May 1, 2020

Conversation

Beytoven
Copy link
Contributor

@Beytoven Beytoven commented Mar 27, 2020

Surfaces the element that is flagged as the LargestContentfulPaint in the LH report. Giving users the specific element gives them a good starting point when looking to reduce their LCP time.

Screen Shot 2020-04-15 at 4 36 14 PM

@Beytoven Beytoven requested a review from a team as a code owner March 27, 2020 19:05
@Beytoven Beytoven requested review from paulirish and removed request for a team March 27, 2020 19:05
Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

looking at your screenshot i dont know why you dont see the outerhtml snippet. this is what i had on paulirish.com:

image

* @return {LH.Audit.Details.Table['items']}
*/
static getNodeData(traceNodes) {
const lcpNode = traceNodes.find(node => node.type === 'lcp');
Copy link
Member

Choose a reason for hiding this comment

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

seeing this type so close to the type thats on L59 makes me think this one should have a different name.. we could go all the way to auditRef or stay with a fairly loose tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opting for metricTag as a replacement

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure where tag came from, but I don't like it. It's being used as an id, but we could just be specific and say metric, since we only plan to have trace nodes that associate with exactly one metric. If that does not hold true sometime in the future, that's fine and we can just change it to id with no issue since this is just an artifact.

*/
function collectTraceNodes() {
/** @type {Array<HTMLElement>} */
// @ts-ignore - put into scope via stringification
Copy link
Member

Choose a reason for hiding this comment

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

could you take care of these lint issues?

* @param {string} attributeName
* @param {string} attributeValue
*/
async setNodeAttribute(nodeId, attributeName, attributeValue) {
Copy link
Member

Choose a reason for hiding this comment

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

IMO its fine to move this method back into your trace-nodes gatherer. and just inline it.

lighthouse-core/gather/gatherers/trace-nodes.js Outdated Show resolved Hide resolved
@@ -41,6 +41,11 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
const descriptionEl = this.dom.find('.lh-metric__description', tmpl);
descriptionEl.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description));

if (audit.result.details) {
Copy link
Member

Choose a reason for hiding this comment

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

convention would be adding something like // HACK! to call out this is a temporary thing ;)

@@ -1522,3 +1522,5 @@
75% { opacity: 1; }
100% { opacity: 1; filter: drop-shadow(1px 0px 1px #aaa) drop-shadow(0px 2px 4px hsla(206, 6%, 25%, 0.15)); pointer-events: auto; }
}

/*# sourceURL=report-styles.css */
Copy link
Member

Choose a reason for hiding this comment

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

👍

@paulirish
Copy link
Member

@Beytoven could you also add the CLS nodes into this PR as well?

@connorjclark
Copy link
Collaborator

connorjclark commented Mar 30, 2020

I don't love hiding this under the metric description toggle. What are some alternatives? At minimum, we could auto-expand metrics if LCP is bad (but would like to see another approach)

@Beytoven
Copy link
Contributor Author

I don't love hiding this under the metric description toggle. What are some alternatives? At minimum, we could auto-expand metrics if LCP is bad (but would like to see another approach)

Neither do I. Adding it there was just easiest for seeing how it shows up in the report. CLS will look even worse since the description is already pretty long. Having a separate, collapsable section may work better as we discussed last week.

@brendankenny
Copy link
Member

Having a separate, collapsable section may work better as we discussed last week.

FWIW this fits the bill as a Diagnostic, so it has a collapsable place already (and could eventually be an opportunity since we have the info on e.g. earlier LCP events). I don't know if that's a good idea until the UI changes tying opportunities/diagnostics to particular metrics make the connection clearer, and I don't know if anyone knows a timeline for that :)

metricTag: string;
selector: string;
nodeLabel?: string;
nodePath: string;
Copy link
Member

Choose a reason for hiding this comment

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

devtoolsNodePath or path is what we use in the artifacts. so let's go with devtoolsNodePath

Copy link
Member

Choose a reason for hiding this comment

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

the rest of these names have consistent names in the artifacts and we're all good.


const UIStrings = {
/** Descriptive title of a diagnostic audit that provides the element that was determined to be the Largest Contentful Paint. */
title: 'Largest Contentful Paint element',
Copy link
Member

Choose a reason for hiding this comment

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

yeah calling this traceElements works for me. lets change to that.

lol even getNodeSelector and getNodeLabel are documented as taking Element/HTMLElement and will fail if passed a textnode/comment node.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

just some nits but LGTM!

lighthouse-core/gather/gatherers/trace-elements.js Outdated Show resolved Hide resolved
lighthouse-core/gather/gatherers/trace-elements.js Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview May 1, 2020 21:31 Inactive
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.

7 participants