In this article, I would like to share three features of PageSpeed Insights (PSI), that is not easy to find in the official documentation. I discovered them while hacking on the Lighthouse plugin and integrating PSI to Treo.sh.
For a context, PSI is a simple yet powerful API by Google, that audits your page using Lighthouse and provides real-world users' data from Chrome UX Report (CrUX).
By default, PSI API returns only performance category. It's possible to pass ?category
argument multiple times and get a report with many Lighthouse categories using one request (available categories: performance
, accessibility
, best-practices
, seo
, pwa
).
curl -i "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://treo.sh&category=pwa&category=seo"
By default, PSI API triggers Lighthouse audit and it takes 10 to 20 seconds to get results.
If you just need CrUX data, like in the case of the field-performance plugin. Add origin:
prefix before the actual URL and get origin-level results immediately:
curl -i "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=origin:https://www.google.com"
To get url-level data, prefix with url:
curl -i "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=url:https://www.google.com&strategy=mobile"
PSI provides a clean UI with field and lab performance data. But sometimes it's useful to see actual Lighthouse report, share, or export it.
Pass "?psiurl" argument to Lighthouse Viewer and it will fetch the PSI API and display the data in a default Lighthouse format.
I'm sure that there's more useful functionality, that is not easy to find in the official documentation. Share your tips in the comments or on Twitter @alekseykulikov_.
would be great if you could list all supported values for the
categories
parameter