[go: nahoru, domu]

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(font-display): limit false positives #9148

Merged
merged 5 commits into from
Jun 14, 2019

Conversation

patrickhulce
Copy link
Collaborator

Summary
In font-display, sometimes we just don't get the content of stylesheets for whatever reason. When this happens we falsely flag fonts as not having font-display values when they do, we just can't see them.

This PR inverts the logic in the audit to limit false positives. Instead of finding a set of passing URLs and failing everything else, we find the set of failing URLs directly.

Related Issues/PRs
addresses user-facing concerns of #8493

@jessepinho
Copy link

@patrickhulce just for future documentation: this only affects pages that use <style> tags and don't have a /*# sourceURL=... */ inside them, correct?

@patrickhulce
Copy link
Collaborator Author

@jessepinho yes, that and any other situation like it in which Chrome is unable to provide us with the content of a stylesheet.

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.

this is a really nice structural change to the audit; makes perfect sense to do it this way now that I've seen it done this way :)

I feel like you're going to vote 👎 on this idea, but how do you feel about an audit warning on stylesheet content we can't see? :):)

lighthouse-core/audits/font-display.js Show resolved Hide resolved
lighthouse-core/test/audits/font-display-test.js Outdated Show resolved Hide resolved
lighthouse-core/audits/font-display.js Outdated Show resolved Hide resolved
lighthouse-core/audits/font-display.js Outdated Show resolved Hide resolved
@patrickhulce
Copy link
Collaborator Author

how do you feel about an audit warning on stylesheet content we can't see?

😆 You were very perceptive, I'm not a huge fan since I think it's mostly noise to the user. But how can I say no to a double smiley face!?

I suppose I'd also personally find it helpful that I'd have to manually check it too.

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!

lighthouse-core/audits/font-display.js Outdated Show resolved Hide resolved
const fontDisplayMatch = declaration.match(/font-display\s*:\s*(\w+)\s*(;|\})/);
const rawFontDisplay = (fontDisplayMatch && fontDisplayMatch[1]) || '';
const hasPassingFontDisplay = PASSING_FONT_DISPLAY_REGEX.test(rawFontDisplay);
const targetURLSet = hasPassingFontDisplay ? passingURLs : failingURLs;
Copy link
Member

Choose a reason for hiding this comment

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

lol this is all my fault

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is also why I didn't do it the first time around lol 😆

lighthouse-core/audits/font-display.js Outdated Show resolved Hide resolved
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@jessepinho
Copy link

👍 to @brendankenny 's comment re: the audit warning. Would be nice to know that Lighthouse is unable to see my stylesheets!

@patrickhulce
Copy link
Collaborator Author

Yep, @jessepinho this has been implemented

@patrickhulce patrickhulce merged commit 76d2b12 into master Jun 14, 2019
@patrickhulce patrickhulce deleted the font_usage_false_positive branch June 14, 2019 15:49
@jessepinho
Copy link

@patrickhulce awesome, thanks for merging! when would I expect to see this in Chrome/PageSpeed Insights?

@patrickhulce
Copy link
Collaborator Author

@jessepinho expect it to be in the next released version of LH (so ~few weeks) at which point it will be reflected in PSI.

Canary Chrome should be soon after that but don't hold your breath for Chrome stable. It will go out with Chrome 77 at the earliest which becomes stable Sept 10.

@jessepinho
Copy link

@patrickhulce Thank you!

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

Successfully merging this pull request may close these issues.

None yet

4 participants