> ## Documentation Index
> Fetch the complete documentation index at: https://docs.37audits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Minifier Auditor

> Checks whether a page and the stylesheets and scripts it references are served minified

<Info>
  **Performance Auditor** — checks whether the HTML document and every referenced stylesheet and script are served minified, reporting one result per resource.
</Info>

<CardGroup cols={2}>
  <Card title="Performance" icon="zap">
    Minified assets are smaller, download faster and parse quicker, which improves Largest Contentful Paint and Time to Interactive.
  </Card>

  <Card title="Per resource" icon="list-checks">
    Every evaluated resource gets its own check, so you can see exactly which file still ships unminified.
  </Card>
</CardGroup>

This auditor fetches the audited page, discovers the stylesheets (`<link href="*.css">`) and scripts (`<script src="*.js">`) it references, fetches each one and scores it with a set of minification heuristics. Each resource produces exactly one check: `FAIL` when it is not minified, `WARNING` when it could not be fetched, or `SUCCESS` when it is minified.

## How it works

1. **Fetch the page** — requests the audited URL (redirects followed). A network failure or non-2xx status produces an `ERROR` response and nothing else is evaluated.
2. **Discover resources** — extracts every `<link>` whose `href` ends in `.css` and every `<script>` whose `src` ends in `.js`; HTML entities in the attribute (`&amp;`) are decoded and relative URLs are resolved against the page URL.
3. **Fetch resources** — downloads each stylesheet and script concurrently (up to 10 at a time, 30-second timeout per resource).
4. **Score minification** — for every fetched body at or above `minSizeBytes`, measures average line length, whitespace ratio, structure density (tags, rules or statements per line) and comment ratio. Each signal that crosses its threshold scores one point; a resource is considered minified when it scores at least 2 of 4. Smaller bodies are not scored: minifying a few hundred bytes saves nothing, and the heuristics cannot tell a one-statement file from a pretty-printed one.
5. **Aggregate** — any unminified resource makes the audit `FAIL`; otherwise any unreachable resource makes it `WARNING`; when every resource is minified the audit is `SUCCESS`.

## Preferences

| Key | Type | Default | Description |
| - | - | - | - |
| `minSizeBytes` | integer (bytes) | `1024` (1 KB) | Resources smaller than this are not checked for minification and pass with a `200` check that says so. Set it per monitored URL on the **Configuration** tab; `0` evaluates every resource. |

An invalid value (missing, negative, fractional, non-numeric) makes the auditor fall back to the default and log a warning.

## What it audits

Every row maps to one `checkRule*` method and one `CheckCode`. CheckCode suffixes use status ranges: `200` success, `300–399` warning, `400–499` fail, `500–599` error. Rules `400`–`402` and `300`–`301` run once per resource, so a page with three unminified scripts yields three `402` checks. The `200` check is likewise emitted once per minified resource rather than once per audit.

| CheckCode | Status | When it fires | Recommendation | Why it matters |
| - | - | - | - | - |
| <a id="37A-MinifierAuditor-400" />`37A-MinifierAuditor-400` | `FAIL` | The HTML document scores below the minification threshold (fewer than 2 of 4 signals). | Minify the HTML served at `{path}` (for example with html-minifier-terser or your framework's production build) to strip whitespace and comments; it currently weighs `{bytes}` bytes. | Unminified HTML carries whitespace and comments that every visitor downloads before anything is shown. Larger pages load slower, especially on mobile, which hurts conversion and Core Web Vitals. |
| <a id="37A-MinifierAuditor-401" />`37A-MinifierAuditor-401` | `FAIL` | A referenced stylesheet scores below the minification threshold. | Minify `{path}` with a CSS minifier (cssnano, clean-css, esbuild) and serve the minified build; it currently weighs `{bytes}` bytes. | Stylesheets block rendering: the browser shows nothing until they are downloaded. Unminified CSS is larger, so the first paint is delayed, which hurts Core Web Vitals and conversion. |
| <a id="37A-MinifierAuditor-402" />`37A-MinifierAuditor-402` | `FAIL` | A referenced script scores below the minification threshold. | Minify `{path}` with a JavaScript minifier (terser, esbuild, swc) and serve the minified build; it currently weighs `{bytes}` bytes. | Unminified scripts take longer to download and parse, delaying the moment the page responds to clicks. Slow pages lose visitors and can rank lower through Core Web Vitals. |
| <a id="37A-MinifierAuditor-300" />`37A-MinifierAuditor-300` | `WARNING` | Fetching a referenced stylesheet or script returned a non-2xx HTTP status, so it could not be scored. | Fix the reference to `{path}` (HTTP `{statusCode}`) or remove it from the page, then re-run the audit. | A stylesheet or script that answers with an error is also failing for visitors, so the page may render unstyled or with broken features. |
| <a id="37A-MinifierAuditor-301" />`37A-MinifierAuditor-301` | `WARNING` | Fetching a referenced stylesheet or script failed (timeout, DNS, TLS, connection refused), so it could not be scored. | Make `{path}` reachable from the public internet (last error: `{error}`) or remove it from the page, then re-run the audit. | A referenced file that cannot be downloaded is likely failing for visitors too, leaving the page unstyled or with broken features. |
| <a id="37A-MinifierAuditor-500" />`37A-MinifierAuditor-500` | `ERROR` | The audited page itself could not be fetched or returned a non-2xx status. | Verify `{url}` is reachable and returns HTTP 200, then re-run the audit. Last error was `{error}`. | — |
| <a id="37A-MinifierAuditor-200" />`37A-MinifierAuditor-200` | `SUCCESS` | A resource (HTML document, stylesheet or script) scores at or above the minification threshold, or is smaller than `minSizeBytes` and therefore not scored (`data.skippedBelowMinSize` is `true`). Emitted once per such resource. | — | — |

Every `FAIL` and `SUCCESS` message quotes the observed metrics, for example: `Stylesheet /css/site.css is not minified: 214 line(s) averaging 23 characters, 28.4% whitespace, 3.1% comments (minification score 0/4, minimum 2).`

## Output documentation

| Status | Description | Test logic |
| - | - | - |
| **SUCCESS** | The page and every referenced stylesheet and script are minified | Every resource scores at least 2 of 4 minification signals; one `200` check per resource. |
| **WARNING** | Everything that could be fetched is minified, but at least one referenced resource was unreachable | No `400`–`402` finding, and at least one resource returned a non-2xx status (`300`) or failed to download (`301`). |
| **FAIL** | At least one resource is served unminified | The HTML document (`400`), a stylesheet (`401`) or a script (`402`) scores below the threshold. The summary message names the first offending resource. |
| **ERROR** | The auditor could not fetch the page | Network failure, invalid URL or non-2xx status on the audited URL (`500`). |

## Risks and considerations

### Unminified assets cost every visitor bytes and CPU

* Whitespace, comments and long identifiers can add 30–60% to the transfer size of CSS and JavaScript, even after gzip or Brotli compression.
* Larger scripts take longer to parse and compile on the main thread, which delays interactivity most on low-end mobile devices.
* Shipping unminified builds to production usually means a development build was deployed, which can also leak source comments and debug code.

### Heuristic detection

* Minification is inferred from line length, whitespace, structure density and comment ratio; it is not a byte-for-byte comparison with a minifier's output.
* Very small files (a few lines) can be judged either way; treat a single borderline result with some care and look at the metrics in the check data.

### What this auditor does not check

* Only `<link href="*.css">` and `<script src="*.js">` references are discovered; stylesheets or scripts served from URLs without those extensions, `@import`ed CSS, dynamically injected scripts and module preloads are not evaluated.
* Inline `<style>` and `<script>` blocks are scored only as part of the HTML document.
* Resources are fetched without the page's Basic Auth credentials, so protected assets report `300`.
* Compression (gzip, Brotli) is covered by the Content Encoding Auditor, not by this one.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.