Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run Lighthouse audits from Node.js, save machine-readable results, and automate comparisons in CI. Lighthouse’s Node API is well suited to repeatable page-level checks for performance, accessibility, Best Practices, and SEO. Agentic browsing needs a qualification: Chrome’s current agent documentation describes that as a live health-check capability, but the material available here does not establish that it is a category you can request through the Lighthouse Node API. Treat it as a related Chrome DevTools workflow, not as a guaranteed Node API option.

What the Lighthouse API audits—and what agentic browsing means

Lighthouse is a Chrome-based auditing engine. It gathers information from a browser run and evaluates it with audits, producing scores, findings, and diagnostic details. GoogleChrome describes Lighthouse as analyzing web apps and pages to collect performance metrics and developer-practice insights. Its familiar categories are Performance, Accessibility, Best Practices, and SEO.

Chrome’s current documentation for agents also describes live checks for accessibility, SEO, best practices, and agentic browsing. That last concept concerns whether AI assistants can understand and interact with a live website. It is a readiness signal for the tested page and workflow—not a search-ranking measure and not proof that a particular AI agent will complete every task.

Keep the two execution surfaces distinct. The Lighthouse Node module is the documented programmatic route for Lighthouse results. Chrome’s agent documentation describes an agent-oriented DevTools capability, but the available documentation does not establish a Node API category name or show that `onlyCategories` can request agentic browsing. Do not add a guessed category string to a Node script and assume it measures the same thing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Lighthouse and run an audit from Node.js

The following example uses the Lighthouse Node module with Chrome launched locally by chrome-launcher. It runs Performance and SEO audits, writes an HTML report and a JSON serialization of the Lighthouse Result, and closes Chrome even if the audit fails. Use Node 22 LTS or later for the current Lighthouse repository requirement described in its README; because requirements can change, pin Node and Lighthouse versions in your project and CI configuration.

1. Install the dependencies

npm install --save-dev lighthouse chrome-launcher

Use a project with ES modules enabled, either by setting "type": "module" in package.json or by saving the script with an .mjs extension. Chrome must be installed and launchable in the environment. For CI, use a controlled Chrome installation rather than relying on whichever browser happens to be present.

2. Save this script as audit.mjs

import fs from 'node:fs/promises';
import lighthouse from 'lighthouse';
import chromeLauncher from 'chrome-launcher';

const url = process.argv[2];
if (!url) {
  console.error('Usage: node audit.mjs https://example.com');
  process.exit(1);
}

let chrome;
try {
  chrome = await chromeLauncher.launch({
    chromeFlags: ['--headless'],
  });

  const options = {
    port: chrome.port,
    logLevel: 'info',
    output: 'html',
    onlyCategories: ['performance', 'seo'],
  };

  const runnerResult = await lighthouse(url, options);
  if (!runnerResult) throw new Error('Lighthouse returned no result');

  await fs.writeFile('lighthouse-report.html', runnerResult.report);
  await fs.writeFile(
    'lighthouse-result.json',
    JSON.stringify(runnerResult.lhr, null, 2),
  );

  console.log('Audited URL:', runnerResult.lhr.finalDisplayedUrl);
  console.log('HTML report: lighthouse-report.html');
  console.log('JSON result: lighthouse-result.json');
} finally {
  if (chrome) await chrome.kill();
}

Run it with node audit.mjs https://example.com. The report property contains the requested report output; lhr is the structured Lighthouse Result. Saving both is useful: HTML is convenient for people inspecting findings, while the result object can be parsed by scripts and CI checks. The script prints finalDisplayedUrl, which helps identify redirects or other changes to the URL Lighthouse ultimately audited.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Restrict the audit scope

Use onlyCategories when you want a consistent subset such as Performance and SEO. For audit-level selection, pass a configuration object as the third argument to the Lighthouse function. A config can extend lighthouse:default and specify onlyAudits. Prefer the smallest scope that answers your question, and keep that scope fixed when comparing runs. If your code expects a score that is not included in the configured audits, the result may not contain the field you expect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Automate checks in CI and compare like with like

A one-off run can help diagnose a page; a CI workflow makes changes visible over time. Lighthouse CI documents automated collection, report diffs, time-series charts, and status checks. Use that workflow when you want to spot regressions across commits rather than making a release decision from one score.

  1. Choose the pages and categories. Select representative URLs and the checks that matter to your project. Keep the list and audit scope stable across builds.
  2. Pin the runtime. Pin the Node and Lighthouse versions, and control which Chrome version CI launches. Record upgrades so a changed result can be interpreted against a changed toolchain.
  3. Hold run conditions steady. Keep device emulation and network settings consistent. Changes in browser, throttling, authentication, or page state can change results independently of a code change.
  4. Collect results for comparable builds. Store reports or use Lighthouse CI’s collection and comparison workflow to inspect diffs, charts, and configured status checks.
  5. Investigate the audit evidence. Open the affected audit and its artifacts before deciding what to fix. Lighthouse separates gathering browser artifacts, including trace data and DevTools protocol logs, from evaluating those inputs with audits.

A status check is only as useful as its scope and repeatability. Establish thresholds that fit your application and investigate how a failing check maps to a user-visible or engineering concern; do not treat an aggregate score as an explanation by itself.

Interpret Performance and SEO scores carefully

Performance is a lab result for a particular run

Lighthouse reports opportunities, diagnostics, and performance metrics for the tested page under the run’s browser and emulation conditions. A score is not a measurement of every real visitor, device, or network. Repeated runs with fixed settings and CI trend data give more useful regression evidence than one isolated result. If the question is how real users experience the site, pair the lab result with an appropriate field-data source and label the two kinds of evidence separately.

SEO is a set of technical page checks, not a ranking forecast

Lighthouse’s SEO score summarizes included technical audits on the page. Its scoring documentation says SEO audits are equally weighted except Structured Data, which is a manual, unscored audit. A high score therefore indicates that the included checks passed; it does not establish rankings, backlink strength, content usefulness, whole-site indexation, or performance in every search market. Compare pages using the same Lighthouse version and configuration.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Agentic browsing is not SEO or a task-completion guarantee

Use agentic-browsing checks, where available in the documented Chrome agent workflow, to examine whether an assistant can understand and interact with the tested page. The result should be read as a signal about that page and workflow. It cannot prove that a specific commercial AI assistant will succeed at an arbitrary task, and it does not replace search, accessibility, or performance checks.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Audit local, staging, and authenticated pages

Lighthouse can audit pages reachable by the Chrome instance it runs against. That includes a local development server when the browser can access it; Chrome’s agent documentation also describes auditing local HTML files opened with file://. For a Node run, pass the local or staging URL to the same script, for example http://localhost:3000/. Start the server before the audit and make sure Chrome runs in the same environment or can reach that host. A container’s localhost is not automatically the host machine’s localhost.

Authenticated pages need deliberate setup. Lighthouse documents approaches including connecting to an existing Chrome debugging session, disabling storage reset, adding request headers, and handling cookies. See the project’s authenticated pages guide for those methods. Record the login state, headers, cookies, and storage behavior used: a logged-out page and a logged-in page are different test subjects, and session expiry can make a run appear to audit the wrong content.

Troubleshoot common Lighthouse API failures

  • Chrome fails to launch: Confirm Chrome is installed, executable in the runtime, and compatible with the environment. In containers or CI, configure the browser installation and launch permissions explicitly rather than assuming a desktop Chrome setup.
  • The audit reports the wrong page: Check redirects and inspect runnerResult.lhr.finalDisplayedUrl. Confirm the intended host is reachable from the browser process.
  • A local URL cannot be reached: Start the development server first, bind it to an address reachable by Chrome, and account for container networking. A host browser and a container browser may resolve localhost differently.
  • An authenticated page looks logged out: Verify the session is valid in the browser context Lighthouse uses. Apply a documented authentication approach and make the cookie, storage-reset, or header configuration repeatable.
  • A result or score is missing: Check that the category or audit is included in your configuration. A deliberately restricted onlyCategories or onlyAudits scope cannot provide excluded data.
  • Scores differ between commits without an obvious code change: Compare Lighthouse and Chrome versions, device and network settings, authentication state, and page readiness. Repeat under fixed conditions before attributing the difference to application code.
  • The run is slow or times out: Check whether the page itself is slow or unstable, whether third-party resources are blocking readiness, and whether CI has enough resources. Avoid changing timeout or wait behavior between compared runs without documenting the change.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

Lighthouse gives you audit scores and diagnostics; a screenshot is a visual capture, not a Lighthouse audit. If you also need a clean image of a page for review or an AI workflow, ScreenshotNeo provides a one-request screenshot API and an MCP server. Its capture options include PNG, JPEG, WebP, or PDF output, and its consent-removal steps can be turned off. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. These features are available on every plan. Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Frequently Asked Questions

Can I use Lighthouse to audit a page behind a login?

Yes, if you provide a repeatable authenticated browser context. Lighthouse documents several approaches, including an existing Chrome debugging session, request headers, cookie handling, and disabling storage reset; the exact choice depends on how the site authenticates.

Does an agentic-browsing check tell me whether an AI agent will finish a task?

No. It is a readiness signal about whether an assistant can understand and interact with the tested page, not a guarantee about a particular agent or task.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.