Created
May 31, 2024 07:40
-
-
Save alexander-danilenko/ec84e9c1b04116f99044eb3eeaa8c546 to your computer and use it in GitHub Desktop.
Lighthouse run against multiple URLs from urls.txt file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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