-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add desktop support, refactor scoring data (#10)
- Loading branch information
1 parent
2880e44
commit 5b2d729
Showing
3 changed files
with
122 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,60 @@ | ||
export const metrics = { | ||
FCP: {auditId: 'first-contentful-paint', name: 'First Contentful Paint'}, | ||
SI: {auditId: 'speed-index', name: 'Speed Index'}, | ||
LCP: {auditId: 'largest-contentful-paint', name: 'Largest Contentful Paint'}, | ||
TTI: {auditId: 'interactive', name: 'Time to Interactive'}, | ||
TBT: {auditId: 'total-blocking-time', name: 'Total Blocking Time'}, | ||
CLS: {auditId: 'cumulative-layout-shift', name: 'Cumulative Layout Shift', units: 'unitless'}, | ||
FMP: {auditId: 'first-meaningful-paint', name: 'First Meaningful Paint'}, | ||
FCI: {auditId: 'first-cpu-idle', name: 'First CPU Idle'}, | ||
}; | ||
|
||
/** | ||
* V6 weights | ||
*/ | ||
|
||
export const weights = { | ||
v5: { | ||
FCP: 0.2, | ||
SI: 0.26666, | ||
FMP: 0.066666, | ||
TTI: 0.33333, | ||
FCI: 0.133333, | ||
}, | ||
export const curves = { | ||
v6: { | ||
FCP: 0.15, | ||
SI: 0.15, | ||
LCP: 0.25, | ||
TTI: 0.15, | ||
TBT: 0.25, | ||
CLS: 0.05 | ||
mobile: { | ||
FCP: {weight: 0.15, median: 4000, p10: 2336}, | ||
SI: {weight: 0.15, median: 5800, p10: 3387}, | ||
LCP: {weight: 0.25, median: 4000, p10: 2500}, | ||
TTI: {weight: 0.15, median: 7300, p10: 3785}, | ||
TBT: {weight: 0.25, median: 600, p10: 287}, | ||
CLS: {weight: 0.05, median: 0.25, p10: 0.1}, | ||
}, | ||
desktop: { | ||
FCP: {weight: 0.15, median: 1600, p10: 934}, | ||
SI: {weight: 0.15, median: 2300, p10: 1311}, | ||
LCP: {weight: 0.25, median: 2400, p10: 1200}, | ||
TTI: {weight: 0.15, median: 4500, p10: 2468}, | ||
TBT: {weight: 0.25, median: 350, p10: 150}, | ||
CLS: {weight: 0.05, median: 0, p10: 0.1}, | ||
}, | ||
}, | ||
v5: { | ||
FCP: {weight: 0.2, median: 4000, podr: 2000}, | ||
SI: {weight: 0.26666, median: 5800, podr: 2900}, | ||
FMP: {weight: 0.066666, median: 4000, podr: 2000}, | ||
TTI: {weight: 0.33333, median: 7300, podr: 2900}, | ||
FCI: {weight: 0.133333, median: 6500, podr: 2900}, | ||
}, | ||
}; | ||
|
||
/** | ||
* V5/v6 scoring curves | ||
* @param {Record<string, {weight: number, median: number, podr: number}>} curves | ||
*/ | ||
export const scoring = { | ||
FCP: {median: 4000, falloff: 2000, auditId: 'first-contentful-paint', name: 'First Contentful Paint'}, | ||
FMP: {median: 4000, falloff: 2000, auditId: 'first-meaningful-paint', name: 'First Meaningful Paint'}, | ||
SI: {median: 5800, falloff: 2900, auditId: 'speed-index', name: 'Speed Index'}, | ||
TTI: {median: 7300, falloff: 2900, auditId: 'interactive', name: 'Time to Interactive'}, | ||
FCI: {median: 6500, falloff: 2900, auditId: 'first-cpu-idle', name: 'First CPU Idle'}, | ||
TBT: {median: 600, falloff: 200, auditId: 'total-blocking-time', name: 'Total Blocking Time'}, | ||
LCP: {median: 4000, falloff: 2000, auditId: 'largest-contentful-paint', name: 'Largest Contentful Paint'}, | ||
CLS: {median: 0.25, falloff: 0.054, auditId: 'cumulative-layout-shift', name: 'Cumulative Layout Shift', units: 'unitless'}, | ||
function makeScoringGuide(curves) { | ||
const scoringGuide = {}; | ||
for (const [key, curve] of Object.entries(curves)) { | ||
scoringGuide[key] = {...metrics[key], ...curve}; | ||
} | ||
return scoringGuide; | ||
} | ||
|
||
export const scoringGuides = { | ||
v6: { | ||
mobile: makeScoringGuide(curves.v6.mobile), | ||
desktop: makeScoringGuide(curves.v6.desktop), | ||
}, | ||
v5: { | ||
mobile: makeScoringGuide(curves.v5), | ||
desktop: makeScoringGuide(curves.v5), | ||
}, | ||
}; |