Google Lighthouse is super valuable but it only checks one page at a time.
Hamlet will show you how to get it to check all pages of a site, and how to run automated Lighthouse checks on-demand at scheduled intervals and from automated tests.
He'll also cover how to set performance budgets, how to get alerts when budgets are exceeded, and how to aggregate page reports using BigQuery and Google Data Studio.
14. AGENDA
HERE IS WHAT WE ARE GOING TO DO:
• Set up a test Gatsby site and deploy it to Netlify
• Set up a Github repository for the site
• Add Github Action to run Lighthouse CI automatically
when new changes are published
• Set up performance budgets to halt deployment to
production if changes lower page speed performance
• Set up a LightHouse CI server to host the reports and to
visualize changes overtime
24. SET UP GITHUB CONNECTION
git config --global user.email hamletb@ranksense.com
git config --global user.name ”Hamlet Batista”
25. GATSBY AND
NETLIFY CMS
SUMMARY GATSBY RUNS PAGES REALLY
FAST THANKS TO STATIC SITE
GENERATION
NETLIFY CMS PROVIDES A UI TO
ALLOW FOR REGULAR CHANGES
IN A GIT WORKFLOW
34. GITHUB AND
NETLIFY
SUMMARY GITHUB NOTIFIES NETLIFY OF
CHANGES IN THE REPO
THROUGH WEBHOOKS
NETLIFY DEPLOYS CHANGES TO
THEIR CDN ONCE IT RECEIVES
THE NOTIFICATIONS
37. • COMMAND LINE TOOL
• SERVER WITH STORAGE AND REPORTING UI
https://github.com/GoogleChrome/lighthouse-ci
LIGHTHOUSE CI
38. USE CASES
Get a Lighthouse report alongside every pull request.
Prevent regressions in accessibility, SEO, offline support, and performance best practices.
Track performance metrics and Lighthouse scores over time.
Set and keep performance budgets on scripts and images.
Run Lighthouse many times to reduce variance.
Compare two versions of your site to find improvements and regressions of individual resources.
43. ADDING THE
LIGHTHOUSE
CI ACTION TO
THE REPO
git clone https://github.com/hamletbatista/gatsby-
starter-netlify-cms.git
cd gatsby-starter-netlify-cms
mkdir .github/workflows/
cd .github/workflows/
44. Adding the Lighthouse CI
Action to the repo (cont.)
• This is the file
.github/workflows/main.yml
• This is all we need to create a test
action
• I left the test URLs in the example.
We will change them later
45. Adding the Lighthouse CI
Action to the repo (cont.)
• git add .
• git commit -m "added LHCI action"
• git push origin master
46.
47. LIGHTHOUSE
AND GITHUB
SUMMARY LIGHTHOUSE CI CAN CHECK URLS
FROM THE COMMAND LINE AND
GENERATE REPORTS ON DEMAND
LHCI GITHUB ACTION ALLOWS US TO
RUN LHCI ON COMMITS TO THE REPO
60. SETTING UP
POSTGRES
• Create an instance
• Set up user and password
• Create a database named lighthouse
• Find your LHCI server P using:
curl ifconfig.co
• In Connections, add this IP to whitelist it.
For example, 35.196.34.79/32
62. STARTING
THE LHCI
SERVER
First, we need to install the Postgres driver for Node using:
npm install -g pg
lhci server --storage.sqlDialect=postgres --
storage.sqlConnectionUrl="postgres://postgres:<password>@<DB
IP>/lighthouse”
We get “Server listening on port 9001”
STARTING
THE LHCI
SERVER
First, we need to install the Postgres driver for Node using:
npm install -g pg
lhci server --storage.sqlDialect=postgres --
storage.sqlConnectionUrl="postgres://postgres:<password>@<DB
IP>/lighthouse”
We get “Server listening on port 9001”
65. LIGHTHOUSE
CI SERVER AND
POSTGRES
SUMMARY LHCI SERVER CAN PERSIST
REPORTS TO A DATABASE
WE CHOOSE POSTGRES WHICH ALLOWS
US TO CONNECT DIRECTLY FROM DATA
STUDIO LATER
66. SENDING REPORTS
TO LHCI SERVER
Setting up our LHCI Github Action to upload
reports to the LHCI Server on every push
67.
68. Updating our workflow
definition
• We add three lines to replace the
temporary storage
• upload.serverBaseUrl: ${{
secrets.LHCI_SERVER }}
• upload.token: ${{
secrets.LHCI_TOKEN }}
70. SENDING
REPORTS TO
LHCI SERVER
SUMMARY LHCI GITHUB ACTION CAN SEND
REPORTS DIRECTLY TO A LHCI SERVER
GITHUB SECRETS CAN KEEP THE
ADDRESS OF THE LHCI SERVER AND
TOKEN PRIVATE
71. We offer guaranteed PSI scores of
+70 in mobile and +80 in desktop
for Shopify stores
Visit to learn more
https://bit.ly/2ECAr6z