How to Build a Screenshot API in Node and Puppeteer
ThatSoftwareDude
Subscribe and get access to my free weekly newsletter where I break down the latest happenings in the world of code
SHARE
ThatSoftwareDude
April 29, 2025
Build a Lightweight Page Speed Analyzer with Lighthouse and Node.js
Sometimes, you just want to know how fast your page really is, without waiting for full dashboards to load or logging into anything. Here’s a lightweight way to do that using Google’s Lighthouse CLI, right from a Node.js script.
This small utility lets you programmatically measure performance, SEO, accessibility, and more. You can run it manually, automate it, or even wrap it in an API later if you need something more robust.
This will generate a full Lighthouse audit in JSON format. You can easily switch to HTML output if needed. The results include:
Overall performance score
First Contentful Paint
Speed Index
Time to Interactive
You can take it further by:
Sending alerts if scores drop below a threshold
Tracking performance trends over time
Why Bother?
Because you shouldn’t need DevTools just to know if your site is sluggish. With a simple script like this, you can benchmark page speed, run it during deployments, or keep an eye on changes, all with minimal setup.
It’s especially useful for developers running blogs, side projects, or lightweight SaaS sites where performance matters but time is limited.
Other Ways to Use Lighthouse
This guide focuses on performance, but Lighthouse offers much more. With the right setup, you can:
Audit for SEO, accessibility, PWA compliance, and best practices
Generate shareable HTML reports with one flag change
Switch between mobile and desktop emulation
Automate audits in your CI/CD pipeline
Monitor competitors’ sites for performance trends
Write custom audits for your own domain-specific needs
With a little creativity, Lighthouse can go from “nice-to-have” to a fully integrated part of your workflow.
Let me know if you want to see how this could be turned into an API or dashboard next.