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(config): use explicit diagnostic group #15901

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 40 additions & 49 deletions core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ const UIStrings = {
budgetsGroupDescription: 'Performance budgets set standards for the performance of your site.',
/** Title of the speed metrics section of the Performance category. Within this section are various speed metrics which quantify the pageload performance into values presented in seconds and milliseconds. */
metricGroupTitle: 'Metrics',
/** Title of the opportunity section of the Performance category. Within this section are audits with imperative titles that suggest actions the user can take to improve the loading performance of their web page. 'Suggestion'/'Optimization'/'Recommendation' are reasonable synonyms for 'opportunity' in this case. */
loadOpportunitiesGroupTitle: 'Opportunities',
/** Description of the opportunity section of the Performance category. 'Suggestions' could also be 'recommendations'. Within this section are audits with imperative titles that suggest actions the user can take to improve the loading performance of their web page. */
loadOpportunitiesGroupDescription: 'These suggestions can help your page load faster. They don\'t [directly affect](https://developer.chrome.com/docs/lighthouse/performance/performance-scoring/) the Performance score.',
/** Title of an opportunity sub-section of the Performance category. Within this section are audits with imperative titles that suggest actions the user can take to improve the time of the first initial render of the webpage. */
firstPaintImprovementsGroupTitle: 'First Paint Improvements',
/** Description of an opportunity sub-section of the Performance category. Within this section are audits with imperative titles that suggest actions the user can take to improve the time of the first initial render of the webpage. */
Expand Down Expand Up @@ -346,10 +342,6 @@ const defaultConfig = {
'metrics': {
title: str_(UIStrings.metricGroupTitle),
},
'load-opportunities': {
title: str_(UIStrings.loadOpportunitiesGroupTitle),
description: str_(UIStrings.loadOpportunitiesGroupDescription),
},
'budgets': {
title: str_(UIStrings.budgetsGroupTitle),
description: str_(UIStrings.budgetsGroupDescription),
Expand Down Expand Up @@ -440,47 +432,46 @@ const defaultConfig = {
{id: 'max-potential-fid', weight: 0, group: 'hidden'},
{id: 'first-meaningful-paint', weight: 0, acronym: 'FMP', group: 'hidden'},

// These audits will be put in "load-opportunities" or "diagnostics" based on their details type.
{id: 'render-blocking-resources', weight: 0},
{id: 'uses-responsive-images', weight: 0},
{id: 'offscreen-images', weight: 0},
{id: 'unminified-css', weight: 0},
{id: 'unminified-javascript', weight: 0},
{id: 'unused-css-rules', weight: 0},
{id: 'unused-javascript', weight: 0},
{id: 'uses-optimized-images', weight: 0},
{id: 'modern-image-formats', weight: 0},
{id: 'uses-text-compression', weight: 0},
{id: 'uses-rel-preconnect', weight: 0},
{id: 'server-response-time', weight: 0},
{id: 'redirects', weight: 0},
{id: 'uses-http2', weight: 0},
{id: 'efficient-animated-content', weight: 0},
{id: 'duplicated-javascript', weight: 0},
{id: 'legacy-javascript', weight: 0},
{id: 'prioritize-lcp-image', weight: 0},
{id: 'total-byte-weight', weight: 0},
{id: 'uses-long-cache-ttl', weight: 0},
{id: 'dom-size', weight: 0},
{id: 'critical-request-chains', weight: 0},
{id: 'user-timings', weight: 0},
{id: 'bootup-time', weight: 0},
{id: 'mainthread-work-breakdown', weight: 0},
{id: 'font-display', weight: 0},
{id: 'third-party-summary', weight: 0},
{id: 'third-party-facades', weight: 0},
{id: 'largest-contentful-paint-element', weight: 0},
{id: 'lcp-lazy-loaded', weight: 0},
{id: 'layout-shifts', weight: 0},
{id: 'uses-passive-event-listeners', weight: 0},
{id: 'no-document-write', weight: 0},
{id: 'long-tasks', weight: 0},
{id: 'non-composited-animations', weight: 0},
{id: 'unsized-images', weight: 0},
{id: 'viewport', weight: 0},
{id: 'uses-responsive-images-snapshot', weight: 0},
{id: 'work-during-interaction', weight: 0},
{id: 'bf-cache', weight: 0},
{id: 'render-blocking-resources', weight: 0, group: 'diagnostics'},
{id: 'uses-responsive-images', weight: 0, group: 'diagnostics'},
{id: 'offscreen-images', weight: 0, group: 'diagnostics'},
{id: 'unminified-css', weight: 0, group: 'diagnostics'},
{id: 'unminified-javascript', weight: 0, group: 'diagnostics'},
{id: 'unused-css-rules', weight: 0, group: 'diagnostics'},
{id: 'unused-javascript', weight: 0, group: 'diagnostics'},
{id: 'uses-optimized-images', weight: 0, group: 'diagnostics'},
{id: 'modern-image-formats', weight: 0, group: 'diagnostics'},
{id: 'uses-text-compression', weight: 0, group: 'diagnostics'},
{id: 'uses-rel-preconnect', weight: 0, group: 'diagnostics'},
{id: 'server-response-time', weight: 0, group: 'diagnostics'},
{id: 'redirects', weight: 0, group: 'diagnostics'},
{id: 'uses-http2', weight: 0, group: 'diagnostics'},
{id: 'efficient-animated-content', weight: 0, group: 'diagnostics'},
{id: 'duplicated-javascript', weight: 0, group: 'diagnostics'},
{id: 'legacy-javascript', weight: 0, group: 'diagnostics'},
{id: 'prioritize-lcp-image', weight: 0, group: 'diagnostics'},
{id: 'total-byte-weight', weight: 0, group: 'diagnostics'},
{id: 'uses-long-cache-ttl', weight: 0, group: 'diagnostics'},
{id: 'dom-size', weight: 0, group: 'diagnostics'},
{id: 'critical-request-chains', weight: 0, group: 'diagnostics'},
{id: 'user-timings', weight: 0, group: 'diagnostics'},
{id: 'bootup-time', weight: 0, group: 'diagnostics'},
{id: 'mainthread-work-breakdown', weight: 0, group: 'diagnostics'},
{id: 'font-display', weight: 0, group: 'diagnostics'},
{id: 'third-party-summary', weight: 0, group: 'diagnostics'},
{id: 'third-party-facades', weight: 0, group: 'diagnostics'},
{id: 'largest-contentful-paint-element', weight: 0, group: 'diagnostics'},
{id: 'lcp-lazy-loaded', weight: 0, group: 'diagnostics'},
{id: 'layout-shifts', weight: 0, group: 'diagnostics'},
{id: 'uses-passive-event-listeners', weight: 0, group: 'diagnostics'},
{id: 'no-document-write', weight: 0, group: 'diagnostics'},
{id: 'long-tasks', weight: 0, group: 'diagnostics'},
{id: 'non-composited-animations', weight: 0, group: 'diagnostics'},
{id: 'unsized-images', weight: 0, group: 'diagnostics'},
{id: 'viewport', weight: 0, group: 'diagnostics'},
{id: 'uses-responsive-images-snapshot', weight: 0, group: 'diagnostics'},
{id: 'work-during-interaction', weight: 0, group: 'diagnostics'},
{id: 'bf-cache', weight: 0, group: 'diagnostics'},

// Budget audits.
{id: 'performance-budget', weight: 0, group: 'budgets'},
Expand Down
32 changes: 21 additions & 11 deletions core/lib/lighthouse-compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,29 @@
}
}

// This backcompat converts old LHRs (<9.0.0) to use the new "hidden" group.
// Old LHRs used "no group" to identify audits that should be hidden in performance instead of the "hidden" group.
// Newer LHRs use "no group" to identify opportunities and diagnostics whose groups are assigned by details type.
// This backcompat converts old LHRs to use the "hidden" and "diagnostics" groups.
// <9.0.0 LHRs used "no group" to identify audits that should be hidden in performance instead of the "hidden" group.
// <9.0.0 LHRs used "load-opportunities" for opportunity audits that are now grouped under "diagnostics".
// >=9.0.0 && <12.0.0 LHRs use "no group" to identify opportunities and diagnostics whose groups are assigned by details type.
// >=12.0.0 LHRs use the "hidden" group to identify hidden audits and "diagnostics" to identify diagnostics. "no group" is meaningless.
const [majorVersion] = lhr.lighthouseVersion.split('.').map(Number);
const perfCategory = lhr.categories['performance'];
if (majorVersion < 9 && perfCategory) {
if (!lhr.categoryGroups) lhr.categoryGroups = {};
lhr.categoryGroups['hidden'] = {title: ''};
for (const auditRef of perfCategory.auditRefs) {
if (!auditRef.group) {
auditRef.group = 'hidden';
} else if (['load-opportunities', 'diagnostics'].includes(auditRef.group)) {
delete auditRef.group;
if (perfCategory) {
if (majorVersion < 9) {
if (!lhr.categoryGroups) lhr.categoryGroups = {};
lhr.categoryGroups['hidden'] = {title: ''};
for (const auditRef of perfCategory.auditRefs) {
if (!auditRef.group) {
auditRef.group = 'hidden';
} else if (auditRef.group === 'load-opportunities') {
auditRef.group = 'diagnostics';
}

Check warning on line 127 in core/lib/lighthouse-compatibility.js

View check run for this annotation

Codecov / codecov/patch

core/lib/lighthouse-compatibility.js#L126-L127

Added lines #L126 - L127 were not covered by tests
}
} else if (majorVersion < 12) {
for (const auditRef of perfCategory.auditRefs) {
if (!auditRef.group) {
auditRef.group = 'diagnostics';
}
}
adamraine marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
Loading
Loading