Skip to content

Instantly share code, notes, and snippets.

@alexander-danilenko
Created May 31, 2024 07:40
Show Gist options
  • Save alexander-danilenko/ec84e9c1b04116f99044eb3eeaa8c546 to your computer and use it in GitHub Desktop.
Save alexander-danilenko/ec84e9c1b04116f99044eb3eeaa8c546 to your computer and use it in GitHub Desktop.
Lighthouse run against multiple URLs from urls.txt file
#!/usr/bin/env bash
urls=$(cat urls.txt)
outDir="results"
mkdir -p $outDir
for url in $urls; do
fileFriendlyUrl=$(echo $url | sed 's/[^a-zA-Z0-9]/_/g')
outFilePath="$outDir/$fileFriendlyUrl.html"
if ! [ -f "$outFilePath" ]; then
echo "[$url] 1st pass. Warming cache..."
lighthouse $url --preset=desktop --quiet --chrome-flags="--headless" --output=html --output-path=/dev/null
echo "[$url] 2nd pass..."
lighthouse $url --preset=desktop --quiet --chrome-flags="--headless --window-size=1920,1080" --output=html --output-path="$outFilePath"
else
echo "Skipping $url, already exists"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment