0

在开发工具中使用Chrome 60时,有一些Audits Panel,其中有一些得分(由Lighthouse驱动)。 Progressive Web App,Performance,Accessibility和Best Practices顶部的分数是您每个类别的总分数。在Chrome中,如何在Javascript中获得审核小组得分

您是否认为可以在Chrome中使用一些Javascript代码访问这些分数?

+0

恐怕我现在没有时间尝试,但本页上的说明看起来很有希望:https://developers.chrome.com/extensions/experimental_devtools_audits –

+0

感谢您的链接。我要去看。 – LeMoussel

+0

Hummm ;;; “使用chrome.experimental.devtools.audits API将新的审核类别添加到”开发者工具审核“面板中。”我没有找到API来获取像Lighthouse这样的审计数据。 – LeMoussel

回答

2

您可以从the command line运行灯塔:

npm install -g lighthouse 
lighthouse --output=json --output-path=./report.json https://airhorner.com/ 

这将产生一个./report.json可以通过脚本来消耗。


也可以在节点脚本中运行Lighthouse。它没有在文档中描述过,但你可以看看other tools(例如webpack-lighthouse-plugin)是如何做的。