During one of my sleepless nights, I played with the Google PageSpeed Insights API . After a few hours, to my immense satisfaction from #wannabedeveloper , I had written a very simple plugin for WordPress to measure Google PageSpeed values.
For the uninitiated, Google PageSpeed Insights is an online tool for measuring page loading speed. APIs, on the other hand, are a method of obtaining information in JSON or XML format simply by querying a server with an HTTP request. I love them… they are a simple method of getting data, I have used them for Entities Finder and for many other experiments.
Now I’ll explain what this plugin is for and how to install it.
What is eve_pagespeed for?
This plugin activates a box while you browse while logged in on your wordpress site.
The box contains the PageSpeed data for the page you are visiting. The box appears below the footer in WordPress installations while it appears at the top, above the header, if you use the Genesis framework .
The data shown in the box are divided by analysis of the Desktop version and the Mobile version. Users who are not logged in do not see the box. This is what the plugin looks like at its 1.1 version:
How eve_pagespeed looks like in WordPress
Obtain an API Key from the Google API Console
First, log into the Google API console .
- Create a new project
- Navigate to the API Library and click on PageSpeed Insights API
- In the new screen at the top click on the ENABLE button
- Navigate to Credentials
- Make a note of your Key
- Close Google API Console
Install the plugin
How to set up eve_pagespeed
- Download the plugin
- Install the plugin and activate it
- Navigate through the settings
- Enter your Key
- Select if you use classic WordPress or the Genesis framework
- Browse the pages of your site to see the PageSpeed scores
API consumption monitoring
Within the Google API console it is possible to monitor in real time the volume of API calls, or in other words the consumption you are making. By default, the PageSpeed Insights API allows 25,000 calls per day with a maximum of 100 calls per second . I doubt that you can consume them by navigating by hand, but if you do, you can always ask for an increase in the number of calls that are granted (there is a button on purpose “Queries quota limit”).
Monitor calls with the Google API Console
Do you have any comments? Leave them in the box below!
The plugin is immature, just born and optimizable from all points of view. Anyone wishing to participate in the development, or simply help me to improve it, is welcome. It will be published in the WordPress plugin repository shortly.
Leave a Reply