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.
1. Audit many categories with one request
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:
curl -i "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://treo.sh&category=pwa&category=seo"
2. Get Chrome UX Report data immediately
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
curl -i "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=url:https://www.google.com&strategy=mobile"
3. View real Lighthouse report
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_.