Skip to content

Lighthouse — alert on a perf-score drop between releases

After a release Lighthouse perf score drops from 90 to 65 (new lib without code-split, or un-minified bundle). You only learn when RUM starts showing LCP > 4 s.

Recipe

bash
#!/usr/bin/env bash
# /etc/cron.d/lighthouse-drop
# 0 */1 * * * root /opt/lighthouse-drop.sh

URL=${URL:-https://example.com}
THRESH=${THRESH:-80}                  # alert below score N

# Headless lighthouse, JSON output
SCORE=$(lighthouse "$URL" \
  --quiet --chrome-flags='--headless' \
  --output=json --output-path=stdout 2>/dev/null \
  | jq '.categories.performance.score * 100 | floor')

if [ "${SCORE:-100}" -lt "$THRESH" ]; then
  curl -fsS "$HEARTBEAT_URL" --data "perf_score=$SCORE,threshold=$THRESH,url=$URL"
  exit 2
fi
echo "OK (perf=$SCORE)"

Same thing in Enterno.io

Use Enterno PageSpeed for score retention — you spot the day LCP jumped and tie it to a commit.

Set up PageSpeed Checker → ← All recipes

Related recipes

long_query_time = 1, slow_query_log enabled. You need to know when the slow-query rate per minute suddenly jumps (a deploy broke an index, ORM went N+1).