Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getExtensionExtraFiles(lhResult) {
const headings = lhResult.audits['bootup-time'].details.headings
const items = getExtensionFiles(lhResult)
const numericValue = items.length
const score = Audit.computeLogNormalScore(numericValue, 0.5, 2) // 0 is optiomal
return {
id: 'exthouse-extension-files',
title: 'Extension files',
description:
'Extension files add extra CPU consumption for every URL visit. Bundle resources into one and leverage hot chaching. [Learn more](https://v8.dev/blog/code-caching-for-devs).',
score,
scoreDisplayMode: 'numeric',
numericValue,
displayValue: `${numericValue} file${numericValue !== 1 ? 's' : ''}`,
details: Audit.makeTableDetails(headings, items)
}
}
{ key: 'startTime', itemType: 'text', text: 'Start Time' },
{ key: 'duration', itemType: 'text', text: 'Duration' }
]
const items = longTasks.map(task => ({
startTime: `${formatMsValue(task.startTime)} ms`,
duration: `${formatMsValue(task.duration)} ms`
}))
return {
id: 'exthouse-new-long-tasks',
title: 'Added Long Tasks',
description: `The value represents a sum of [Long Tasks](https://developer.mozilla.org/en-US/docs/Web/API/Long_Tasks_API) added by extension. The table displays all long tasks occured.`,
score,
scoreDisplayMode: 'numeric',
numericValue,
displayValue: `${formatMsValue(numericValue)} ms`,
details: Audit.makeTableDetails(headings, items) // FIXME: display only new tasks
}
}
const normMax = formatValue(max, { isMs: isMs(timeUnit) })
if (min === 0) {
item.category = `Fast (faster than ${normMax} ${timeUnit})`
} else if (max && min === distributions[index - 1].max) {
item.category = `Average (from ${normMin} ${timeUnit} to ${normMax} ${timeUnit})`
} else {
item.category = `Slow (longer than ${normMin} ${timeUnit})`
}
item.distribution = `${(proportion * 100).toFixed()} %`
return item
})
return Audit.makeTableDetails(headings, items)
}
const [first, ...rest] = checks
const sortedRest = sortBy(rest, ["hostedby", "green"])
const sortedChecks = [first, ...sortedRest]
const results = sortedChecks.map(check => {
const url = `https://${check.url}`
const hostedby = check.hostedby
const green = check.green ? "Green" : "Grey"
const gwfLink = {
type: "link",
text: "view report",
url: `https://www.thegreenwebfoundation.org/green-web-check/?url=${url}`
}
return { url , hostedby, green, gwfLink }
})
return Audit.makeTableDetails(headings, results)
}