justinholtweb/craft-lightning
最新稳定版本:5.0.0
Composer 安装命令:
composer require justinholtweb/craft-lightning
包简介
Google PageSpeed Insights integration for Craft CMS — dashboard widget and entry-level performance auditing with Core Web Vitals metrics and optimization suggestions.
关键字:
README 文档
README
Google PageSpeed Insights for Craft CMS 5. Get performance scores, Core Web Vitals, and optimization suggestions right inside the control panel.
Features
- Dashboard widget — monitor any URL with a one-click audit
- Entry sidebar panel — automatically appears on entries with public URLs
- Core Web Vitals — FCP, LCP, TBT, CLS, and Speed Index with color-coded scores
- Optimization suggestions — ranked opportunities with estimated time savings
- Diagnostics — additional performance issues flagged by Lighthouse
- Mobile & Desktop — audit both strategies with a tabbed interface
- Environment variable support — store your API key in
.env
Requirements
- Craft CMS 5.3.0 or later
- PHP 8.2 or later
- A Google PageSpeed Insights API key
Installation
Add the repository and require the package with Composer:
composer require justinholtweb/craft-lightning
Then install the plugin:
php craft plugin/install lightning
Or install from the control panel under Settings > Plugins.
Setup
- Get a free API key from the Google Cloud Console
- Enable the PageSpeed Insights API in your Google Cloud project
- In the Craft control panel, go to Settings > Lightning
- Enter your API key (or use an environment variable like
$GOOGLE_PSI_API_KEY) - Choose a default strategy (Mobile, Desktop, or Both)
Using an environment variable
Add to your .env file:
GOOGLE_PSI_API_KEY=your-key-here
Then enter $GOOGLE_PSI_API_KEY in the plugin settings.
Usage
Dashboard Widget
- Go to the Dashboard
- Click New Widget > PageSpeed Insights
- Enter the URL to audit and choose a strategy
- Click Run Audit to see results
Add multiple widgets to monitor different pages.
Entry Sidebar
The sidebar panel appears automatically on any entry that has a public URL. Click Run Audit to get the current performance data for that entry's page.
Scores
Scores follow Google's thresholds:
| Range | Rating |
|---|---|
| 90–100 | Good (green) |
| 50–89 | Needs Improvement (orange) |
| 0–49 | Poor (red) |
API Rate Limits
With an API key, you get approximately 25,000 requests per day. Each "Both" audit uses 2 requests (one mobile, one desktop). Without a key the API will not work — a key is required in plugin settings.
License
This plugin is licensed under The Craft License.
Development
Install dependencies and run the test suite:
composer install
composer test
Static analysis and code style checks are also available:
composer phpstan composer check-cs
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-06-11