When opening Pagespeed UI and running a URL, the top section with the core web vitals pretty much appears instantly. In my current use case, I am only interested in that part, and not the Lighthouse diagnostics below (that take several seconds to load).
But when calling the API, I cannot find a way to exclude the lighthouseResults (to boost performance). I did play with category
, but couldn't find a way to speed things up (no matter which category I choose, it's between 15-20s per url).
Reference:
https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https%3A%2F%2Fdevelopers.google.com
So, is there a way to only get the web vitals section? (in the response, that corresponds to loadingExperience
and originLoadingExperience
)
Note: in the end, I am trying to use the googleapis
library in node/TS, but could also implement the API directly.
thanks!
You’re looking for the Chrome User Experience (CrUX) API rather than the PageSpeed Insights API. More details here: https://developer.chrome.com/docs/crux/api/
The CrUX data is a simple retrieval of field data that is precalculated based on previous 28-days usage in Chrome. So it is quick to return.
The rest of PageSpeed Insights is a live test of the site as it is now, using Lighthouse. This takes time to complete, but does mean it will update if you push out changes.
The PSI API returns both, but the CrUX data is also available in a lighter, much quicker, separate API.