π Lighthouse Performance Monitor
Automated Lighthouse performance monitoring and trend analysis tool for web applications. Tracks performance, accessibility, SEO, and best practices metrics over time with beautiful visualizations.
π Overview
This tool automates daily Lighthouse analysis of web applications, collecting performance metrics and generating comprehensive trend visualizations. Perfect for tracking website performance improvements and regressions over time.
Key Features:
- β Automated daily Lighthouse audits
- β Historical trend tracking (months of data)
- β Beautiful 2x2 grid visualizations
- β JSON export for further analysis
- β Min/Max value indicators
- β Easy cron job integration
π§Ύ Project Summary
- Purpose: Automated daily Lighthouseβ¦
π Lighthouse Performance Monitor
Automated Lighthouse performance monitoring and trend analysis tool for web applications. Tracks performance, accessibility, SEO, and best practices metrics over time with beautiful visualizations.
π Overview
This tool automates daily Lighthouse analysis of web applications, collecting performance metrics and generating comprehensive trend visualizations. Perfect for tracking website performance improvements and regressions over time.
Key Features:
- β Automated daily Lighthouse audits
- β Historical trend tracking (months of data)
- β Beautiful 2x2 grid visualizations
- β JSON export for further analysis
- β Min/Max value indicators
- β Easy cron job integration
π§Ύ Project Summary
- Purpose: Automated daily Lighthouse analysis with historical trend tracking
- Method: Daily cron job collects Lighthouse scores and stores them as JSON and visual charts
- Technologies: Node.js (Lighthouse), Python (pandas, matplotlib), shell script
- Outputs: Daily reports and trend visualizations
- Chart folder:
trend/ - Data folder: Configured in
Lighthouse Report Script.js
π¦ Project Structure
lighthouse-performance-monitor/
βββ run-all.sh # Main automation script
βββ Lighthouse Report Script.js # Lighthouse analysis runner
βββ analyze-lighthouse-reports.js # JSON summary generator from reports
βββ plot_lighthouse_summary.py # Trend visualization generator
βββ requirements.txt # Python dependencies
βββ package.json # Node.js dependencies
βββ README.md # This file
βββ .gitignore # Git ignore rules
βββ data/ # Data storage folder (configurable)
β βββ report-YYYY-MM-DD.json # Daily Lighthouse reports
β βββ YYYY-MM-DD/ # Alternative folder structure
β βββ report.json
βββ trend/ # Generated charts
β βββ trend_YYYY-MM-DD_HH-MM-SS.png
βββ report-summary.csv # Aggregated metrics
π§° Installation
Prerequisites
- Node.js (v14+)
- Python 3.7+
- npm
Setup Steps
Clone the repository:
git clone https://github.com/c3nk/lighthouse-performance-monitor.git
cd lighthouse-performance-monitor
Install Python dependencies:
python3 -m venv venv-lighthouse
source venv-lighthouse/bin/activate
pip install -r requirements.txt
Install Node.js dependencies:
npm install
Make script executable:
chmod +x run-all.sh
Configure your website URL: Edit Lighthouse Report Script.js and update the domain variable:
const domain = 'https://example.com'; // Replace with your target website URL
βΆοΈ Usage
Manual Run
Simply execute the main script:
./run-all.sh
This will:
- Run Lighthouse analysis on your configured website
- Generate JSON summary from all historical reports
- Create trend visualization charts
Script Commands
You can also run individual components:
# Run Lighthouse analysis only
npm run lighthouse
# Generate CSV from reports
npm run analyze
# Generate charts only
npm run plot
π Automation (Cron Job)
Set up a daily cron job to automate the analysis:
# Edit crontab
crontab -e
# Add this line (runs daily at 6 AM)
# Replace /path/to/ with the actual absolute path to your project directory
0 6 * * * /path/to/lighthouse-performance-monitor/run-all.sh >> /path/to/lighthouse-performance-monitor/lighthouse.log 2>&1
Note:
- Make sure to provide absolute paths in the cron job
- Replace
/path/to/with your actual project directory path (e.g.,/home/user/projects/)
π Understanding the Output
JSON Summary (report-summary.csv)
Contains daily metrics with columns:
Date: Analysis datePerformance: Performance score (0-100)Accessibility: Accessibility score (0-100)BestPractices: Best practices score (0-100)SEO: SEO score (0-100)
Trend Charts (trend/trend_YYYY-MM-DD_HH-MM-SS.png)
Beautiful 2x2 grid visualization showing:
- Performance Trend: Performance metrics over time
- Accessibility Trend: Accessibility metrics over time
- SEO Trend: SEO metrics over time
- Best Practices Trend: Best practices metrics over time
Each chart includes:
- Line graph showing score progression
- Min/Max value indicators (red/green dots)
- Date range from oldest to newest data
βοΈ Configuration
Changing the Analyzed Website
Edit Lighthouse Report Script.js:
const domain = 'https://example.com'; // Replace with your target website URL
Changing Data Storage Location
Edit Lighthouse Report Script.js and analyze-lighthouse-reports.js:
// In Lighthouse Report Script.js:
const folder = './data/' + now.toISOString().split('T')[0]; // Change 'data' to your preferred folder name
// In analyze-lighthouse-reports.js:
const baseDir = './data'; // Must match the folder name used above
Lighthouse Options
Modify Lighthouse flags in Lighthouse Report Script.js:
exec(`npx lighthouse ${domain} --output json --output-path=${outputFile} --emulated-form-factor=desktop --chrome-flags="--headless"`, ...);
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License is a permissive free software license that allows anyone to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software without restriction. You are free to use this project for any purpose, including commercial purposes, with minimal restrictions.