提问人:Heghar Hex 提问时间:10/11/2023 更新时间:10/11/2023 访问量:16
如何避免在灯塔中达到 5s 警告的收集预算
how to avoid Reached gathering budget of 5s warning in lighthouse
问:
如何在 Lighthouse 中避免此警告:
LH:artifacts:getArtifact ImageElements +35毫秒
LH:ImageElements:warn 达到 5 秒的收集预算。跳过了 281/314 +6s 的额外细节
我有以下代码用于生成灯塔审计报告:
async function runLighthouse(url, outputPath, iterations) {
const chrome = await chromeLauncher.launch({ chromeFlags: ["--headless"] });
for (let i = 0; i < iterations; i++) {
const options = {
// disableStorageReset: true, // Disable clearing the browser storage between runs
logLevel: "info",
output: "json",
port: chrome.port,
throttling: {
method: "devtools",
devtools: {
networkThrottling: {
downloadThroughputKbps: 1000,
},
cpuThrottling: 4, // Simulate slower CPU for more consistent results
},
},
emulatedFormFactor: 'desktop',
};
const runnerResult = await lighthouse(url, options);
const filename = `${outputPath}/${i + 1}.json`;
const reportJson = runnerResult.report;
fs.writeFileSync(filename, reportJson);
console.log(`Lighthouse report saved to ${filename}`);
}
await chrome.kill();
}
答: 暂无答案
评论