SpeedyGo connects to the official Google PageSpeed Insights API to fetch real-time performance reports for your website URL directly inside the WordPress dashboard.
24.1 Overview #
When you click Run Analysis, the plugin performs the following process:
- Triggers an AJAX request:
speedygo_ajax_run_pagespeed - Executes a server-side cURL request
- Sends the request to Google’s PageSpeed API endpoint
- Retrieves a structured JSON response
- Parses and displays performance metrics inside the dashboard
Technical Context #
- Uses
admin-ajax.phpfor secure AJAX handling - Performs a server-side
cURLAPI call - Accepts user-defined timeout values
- Prevents script exhaustion on slow servers
- Sanitizes and validates URL before request
- Securely parses JSON response
24.2 How to Generate Google PageSpeed API Key #
Follow these steps to generate your API key:
- Go to https://console.cloud.google.com/
- Create a new project (or select an existing one)
- Navigate to APIs & Services → Library
- Search for PageSpeed Insights API
- Click Enable
- Go to APIs & Services → Credentials
- Click Create Credentials → API Key
- Copy the generated API key
- Paste it inside SpeedyGo → Settings → PageSpeed
Recommended Security Step:
- Restrict the API key to HTTP referrers or specific IP addresses
- Limit usage quota to prevent abuse
24.3 Server Requirements #
- cURL must be enabled on the server
- Outbound HTTPS requests must be allowed
- PHP execution time should allow API response handling
24.4 Best Practice Recommendation #
- Use moderate timeout values (15–30 seconds)
- Run analysis after clearing cache for accurate results
- Test both Mobile and Desktop reports
Google PageSpeed API Integration allows direct performance monitoring within SpeedyGo for continuous optimization.