Lighthouse によるウェブアプリの監査 | Tools for Web Developers | Google Developers
整形用スクリプト
format-lighthouse-stats.js
const input = require('fs')
.readFileSync('/dev/stdin')
.toString()
const stats = JSON.parse(input)
const scoreMap = Object.entries(stats.audits).reduce((acc, [key, a]) => {
if (typeof a.score === 'number') {
return Object.assign({}, acc, {[key]: a.score })
}
return acc
}, {})
console.log(scoreMap)
点数を見る
$ npm i -g lighthouse # lighthouse-cli をインストール
$ lighthouse https://google.com --output json --quiet | node format-lighthouse-stats.js
{ 'first-meaningful-paint': 86,
'speed-index-metric': 81,
'screenshot-thumbnails': 100,
'estimated-input-latency': 100,
'first-interactive': 70,
'consistently-interactive': 70,
'image-aspect-ratio': 0,
'total-byte-weight': 100,
'offscreen-images': 100,
'uses-webp-images': 100,
'uses-optimized-images': 100,
'uses-request-compression': 100,
'uses-responsive-images': 100,
'dom-size': 100,
'link-blocking-first-paint': 100,
'script-blocking-first-paint': 100 }