In November 2018, Google released an updated PageSpeed Insights API, which provides performance reports from both lab and field data on a page. Using the PageSpeed Insights API, we can test multiple URLs at once to get a better idea of our site’s overall performance and identify areas of our site that can be optimized for speed. To do this, I wrote a script that uses the new PageSpeed Insights API to retrieve performance data and print the results in a Google Sheet—the easiest and quickest way to get an overview of your site’s speed using a sample of pages.
Before you follow optimization recommendations from PageSpeed Insights, it’s important to note that the tool often recommends actions that won’t improve user experience or provide a worthwhile performance increase for your specific site. For example, PageSpeed Insights may advise caching external files (e.g. requests to Facebook.com) or serving images in WebP format, a file type that is not supported across all browsers. It’s important to consider the nuances of your site and your end users when looking at PageSpeed’s recommendations and determining if you should put them into action—look for the biggest payoffs that won’t negatively impact your site’s UX.
Access for free.
How to use the script
The script is configured to test for mobile performance.
-
First, you’ll want to create a copy of the sheet. Open up the sheet, and click “File” and then “Make a Copy”
-
Enter a list of URLs you want to test in Column A on the “InputData” tab
-
Click the “Page Speed” menu item, and then click “Get Page Speed” from the drop-down to execute the script for the list of URLs in Column A
- The first time you run the script, you will be prompted by Google to authorize the request:
-
When the script finishes executing (which could take a number of minutes depending on how many URLs you entered), the results will be printed on the tab “PageSpeedResults”
- If a cell is left blank, that means that item is already optimized on that page.
Response Data
There are 17 columns on the PageSpeedResults tab. The first column contains the URL tested, and the following 16 columns contain the results of the performance tests. The “Performance Score” is an overall rating of your site’s speed performance, with a .1 indicating a slow site and a .9 a fast site. The last column contains a link to the full Pagespeed Lighthouse Report, where you can view all the result data.
What are your favorite metrics to look at when testing page speed? Leave us a comment below or tweet us @distilled.
The Easiest Tool for Testing Page Speed - PageSpeed Insights API was originally posted by Internet Marketing
No comments:
Post a Comment