Using performance budgets | lighthouse-rust | Spatie      

 SPATIE  

lighthouse-rust
===============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Lighthouse-rust](https://spatie.be/docs/lighthouse-rust/v1)  Usage  Using performance budgets

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/lighthouse-rust/v1) 

  Using performance budgets    
- [ Introduction ](https://spatie.be/docs/lighthouse-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/lighthouse-rust/v1/support-us)
- [ Requirements ](https://spatie.be/docs/lighthouse-rust/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/lighthouse-rust/v1/installation-setup)
- [ Testing ](https://spatie.be/docs/lighthouse-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/lighthouse-rust/v1/changelog)

Usage
-----

- [ Generating your first report ](https://spatie.be/docs/lighthouse-rust/v1/usage/generating-your-first-report)
- [ Configuring a run ](https://spatie.be/docs/lighthouse-rust/v1/usage/configuring-a-run)
- [ Working with results ](https://spatie.be/docs/lighthouse-rust/v1/usage/working-with-results)
- [ Saving an HTML report ](https://spatie.be/docs/lighthouse-rust/v1/usage/saving-an-html-report)
- [ Using performance budgets ](https://spatie.be/docs/lighthouse-rust/v1/usage/using-performance-budgets)

 Using performance budgets
=========================

Lighthouse 11 has an interesting feature where you can specify so-called budgets. You can, for example, specify the maximum amount of time for the time-to-interactive metric, or the maximum amount (measured in KB) of JavaScript your page may contain.

Lighthouse 12 removed this feature. To run these audits, install `lighthouse@11.7.1` instead of the current version. The wrapper does not recreate removed upstream audits. Prefer current Lighthouse when you do not need legacy budgets.

You can learn more about this feature in [Use Lighthouse for performance budgets at web.dev](https://web.dev/articles/use-lighthouse-for-performance-budgets).

You can pass your performance budget as a list of JSON objects to `budgets()`.

```
let result = Lighthouse::url(url)?
    .budgets(vec![serde_json::json!({
        "timings": [
            {"metric": "interactive", "budget": 5000}
        ],
        "resourceSizes": [
            {"resourceType": "script", "budget": 170}
        ]
    })])
    .run()?;
```

Budget keys and units follow Lighthouse 11's JSON schema. Time to interactive is no longer scored in the performance category, but remains available to its budget audit.

In the [HTML report](/docs/lighthouse-rust/v1/usage/saving-an-html-report), you can see the results of your budget. The screenshot below comes from the original PHP documentation.

![Lighthouse budget report](https://spatie.be/docs/lighthouse-php/v2/images/budget.jpg)

You can get the budget audit results by calling `budget_results()`.

```
let budgets = result.budget_results();
```

The map includes every audit whose identifier ends with `-budget`, typically `performance-budget` and `timing-budget`. Each value retains Lighthouse's JSON fields, including `details`, `headings` and `items`. It is empty when the report contains no budget audits.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
