Imagine a friendly Github Action bot that adds this to all the PRs (per commit) to your repo:
Web pages with Google Lighthouse metrics that are green (>= 90) tend to be faster, more accessible, and come with a better user experience. If you, as a developer, can help your company improve on these metrics it will directly impact your companies bottom line (+ help with your paid marketing efforts and SEO).
The first step to green Lighthouse metrics is to measure the metrics. Make it easy for you, and your fellow developers, to see how your code changes impact the Lighthouse metrics by including the metrics as a part of your PRs.
- Get the preview url for the PR (from Vercel).
- Run a Lighthouse audit on the preview url with this plugin.
- Format the score to a table (+throw in a few emojis).
- Post a comment on the PR with the formatted score.
The comment on the PR will be a sticky comment - e.g. if the comment exists update it else add a new comment.
The complete action can be found here here. Feel free to copy paste this action to your repo.
- Update step 1 of the action (and get the preview url from e.g. Netlify or from your own deployment setup)
- Always runs the Lighthouse audit on the root page.
- Combine the action with a budget to prevent PRs that bring the metrics below a set treshhold.
- Run the audit only on the pages affected by the PR.
- Compare the collected metrics with the actual metrics of your production site.
Did this help you out? Like and share the article and follow me on Twitter (i'm building Glitterly - a web based video editor).