LoginSignup
9
8

More than 5 years have passed since last update.

lighthouse のスコアを CLI だけで確認する

Last updated at Posted at 2018-01-26

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 }

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8