-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
refactor: DRY byte efficiency audits #1635
Conversation
@patrickhulce this will need a rebase. Rebasing against the latest master will also pick up #1654. |
PTAL, I'll update smoke tests once there's general agreement on the more lax thresholds. |
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.
I'm liking this. My only concern vs if this was just done with a helper function would be what happens when we get a byte efficiency audit that doesn't completely fit this mold (e.g. JS usage...we'd also want to report potential savings on compile/parse time) but I think this refactor leaves us in a good position to handle that, actually.
I haven't thought at all about the new thresholds so others will have to comment there :)
For smokehouse, it would be a shame to lose it for testing these audits. We probably do want to add some assets big enough to hit the thresholds, but replacing everything might be excessive.
One option (tell me if this is crazy) would be to add something to the extended info that doesn't end up in the table, so you'd still have value: {results, tableHeadings}
, but also a negligibleResults
or whatever property with the filtered out stuff. It would add noise (and size) to the raw results for results that ostensibly don't matter mostly just to make tests happy, so might not be worth it.
|
||
const KB_IN_BYTES = 1024; | ||
|
||
class UnusedBytes extends Audit { |
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.
can you add a brief class description, basically this is the base class for byte efficiency audits, subclass and override audit_ to write your own?
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.
will do!
Thanks for braving the scary diff @brendankenny! :)
I think we can refactor the shared pieces between that audit and these to a helper, but there's so much shared between generating the audit results here it felt like a waste to do anything less.
Agreed, what about moving these to a new folder and start matching our smokehouse expectations files to our folder structure? That way there's less noise too. We'd only really introduce a minimum of ~100k total to exercise failure in each of these. |
Yeah sounds good, I like 'loading unnecessary CSS'
…On Mon, Feb 13, 2017 at 10:40 AM, Eric Bidelman ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lighthouse-core/audits/byte-efficiency/unused-css-rules.js
<#1635 (review)>
:
> @@ -32,7 +29,7 @@ class UnusedCSSRules extends Audit {
return {
category: 'CSS',
name: 'unused-css-rules',
- description: 'Uses 90% of its CSS rules',
+ description: 'Avoids unnecessary CSS',
"unnecessary CSS" might not be descriptive enough.
What do you think about Avoids including unnecessary CSS or Avoids
loading unnecessary CSS to correlate with the theme of reducing bytes on
page load?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1635 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACMdEkBGNc0rfk4Qxjyb7dX_C1g9c-NLks5rcKOpgaJpZM4L2_SE>
.
|
@@ -41,7 +40,7 @@ class UsesOptimizedImages extends Audit { | |||
return { | |||
category: 'Images', | |||
name: 'uses-optimized-images', | |||
description: 'Has optimized images', | |||
description: 'Avoids unoptimized images', |
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.
Affirmative descriptions still feel better to me (where we can use them). How about aligning with PSI? They use a singular "Optimize images". WDYT about "Optimizes images" for us?
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.
I switched them because I sympathized with the idea that telling users they did something when that thing doesn't apply to them doesn't make a lot of sense. I like the affirmative descriptions in isolation, but I do think consistency between audits within a category that's all about not doing something (shipping bytes) feels a lot smoother.
I definitely prefer "Optimizes images" to the double negative here, but could use guidance on the CSS affirmative, Uses most of its CSS
is pretty lame
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.
telling users they did something when that thing doesn't apply to them
Sort of why I think "Uses optimized images" is better than PSI's "Optimizes images".
The first says: "All the images LH found were optimized. Good job!"
The second says: "You're (actively) optimizing images" ...which as you say, may not be the case.
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.
Any thoughts on CSS wording changes to also be affirmative? I'll give up soon if you don't have any ideas either I'll just live with the mismatch to push this through, haha :P
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.
Yea......hmm. We can stick with "avoids *" for now.
@@ -32,7 +29,7 @@ class UnusedCSSRules extends Audit { | |||
return { | |||
category: 'CSS', | |||
name: 'unused-css-rules', | |||
description: 'Uses 90% of its CSS rules', | |||
description: 'Avoids unnecessary CSS', |
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.
"unnecessary CSS" might not be descriptive enough.
What do you think about Avoids including unnecessary CSS or Avoids loading unnecessary CSS to correlate with the theme of reducing bytes on page load?
preview: '', | ||
url: 'URL', | ||
totalKb: 'Original (KB)', | ||
wastedKb: 'Savings (KB)', |
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.
just a thought: should we put total savings last...as a way to indicate it's representative of the webp/jpeg column that provides the most impact.
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.
+1 I like that idea, also makes the math clear ORIG x PERCENT = SAVINGS
@@ -39,7 +38,7 @@ class UsesResponsiveImages extends Audit { | |||
return { | |||
category: 'Images', | |||
name: 'uses-responsive-images', | |||
description: 'Has appropriately sized images', | |||
description: 'Avoids oversized images', |
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.
"Uses appropriately sized images" or "Loads appropriately sized images"?
updated smokehouse to have a new byte efficiency tester since there were no objections, tests should pass now PTAL :) |
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.
from me
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
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.
A few smallish things
- kill "potential savings %" column and mostly merge it in to last column. So, the last column reads as "Potential Savings" and values are like
186 KB (60%)
. - Since all the values in these tables include their own units, we don't need the headers to indicate units too. It also makes the headers longer, when we'd prefer to give that horizontal space to the URL.
- Title is a little awkward to read.
I'd go with "Avoids loading unnecessary CSS: Potential savings of 15KB (~70ms of page load)"
with @paulirish's improvements: |
love it. |
R: @pavelfeldman all
How it looks now
(CSS Usage is green because this was run without throttling and it wouldn't have saved at least 10ms)
Examples of Verge de-noising
Before
![image](https://cloud.githubusercontent.com/assets/2301202/22842519/53c471fa-ef8a-11e6-863d-63e611741a36.png)
![image](https://cloud.githubusercontent.com/assets/2301202/22842506/46c71afc-ef8a-11e6-9edb-f8852e25b325.png)
After
fixes #1612
The smokehouse tests will fail thanks to us ignoring negligible results now. Not sure if we can find an elegant way of lowering the threshold or we have to just use full-size examples in smokehouse.