Skip to content

How to use performance budgets with flow API #14276

Answered by adamraine
chatur-sriganesh asked this question in Q&A
Discussion options

You must be logged in to vote

You can define budgets on the config:

import * as flowApi from 'lighthouse/core/fraggle-rock/api.js';
import puppeteer from 'puppeteer';
import fs from 'fs';

const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage()

const config = {
  extends: 'lighthouse:default',
  settings: {
    budgets: [
      {
        path: '/*',
        resourceSizes: [
          {
            resourceType: 'script',
            budget: 200
          }
        ]
      }
    ]
  }
}

const flow = await flowApi.startFlow(page, {config});

await flow.navigate('https://paulirish.com');

const report = await flow.generateReport();
fs.writeFileSync('flow.report.html', report);

a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chatur-sriganesh
Comment options

Answer selected by chatur-sriganesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #14274 on August 10, 2022 16:53.