# Token efficiency (content-to-markup ratio)

> Token efficiency (content-to-markup ratio): A bloated DOM wastes an agent's context window. The fix: improve the content-to-markup ratio.

- Source: /checks/token-efficiency
- Site: AgenticWebScore
- Language: English

---
A bloated DOM wastes an agent's context window.

| Property | Value |
| --- | --- |
| Check id | `token-efficiency` |
| Dimension | Content Accessibility (22%) |
| Tier | Recommended — pool 20 pts |
| Weight inside tier | 2 |
| Impact | Medium |
| Maturity | Draft — A published specification that is not yet ratified. |
| Conditional | No |
| Publishing skill | `token-efficiency` |
| Standards | — |

## What is measured

The scanner strips `<script>`, `<style>`, `<svg>` and `<template>` blocks from the homepage `/`, removes the remaining tags, normalises whitespace and divides visible characters by the raw HTML size. Pass when text is at least 15% of the page; partial between 8% and 14.9%; fail below 8%, where the markup an agent must read outweighs the content.

## Reproduce it yourself

You do not have to take our word for any of this. Run the same measurement against your own domain:

```bash
DOMAIN="https://example.com"
html=$(curl -sL "$DOMAIN/"); text=$(printf '%s' "$html" | perl -0777 -pe 's{<(script|style|svg|template|noscript)[^>]*>.*?</\1>}{}gsi; s/<[^>]*>/ /g; s/\s+/ /g'); printf 'text=%d chars, html=%d chars, ratio=%d%%\n' "${#text}" "${#html}" "$(( ${#text} * 100 / ${#html} ))"
```

## The fix

This is the artifact to ship. It is the complete change, not a description of one.

```javascript
// scripts/tighten-html.mjs — run after the build over every emitted page.
import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { minify } from 'html-minifier-terser';

const walk = (dir) => readdirSync(dir).flatMap((name) => {
  const p = join(dir, name);
  return statSync(p).isDirectory() ? walk(p) : p.endsWith('.html') ? [p] : [];
});

for (const file of walk('dist')) {
  const before = readFileSync(file, 'utf8');
  const after = await minify(before, {
    collapseWhitespace: true,
    removeComments: true,
    removeRedundantAttributes: true,
    minifyCSS: true,
    minifyJS: true,
  });
  writeFileSync(file, after);
  console.log(`${file}: ${before.length} -> ${after.length} bytes`);
}
```

> Minification recovers 10-20% of bytes; the real gain is deleting wrapper divs, inline SVG and unused framework markup, so measure before and after with the same command.

## Related checks

| Check | Tier | Impact | Same skill |
| --- | --- | --- | --- |
| `markdown-negotiation` — Markdown content negotiation | Recommended | Critical | — |
| `headings` — Semantic heading structure | Essential | High | — |
| `meta` — Title and summary metadata | Essential | High | — |
| `jsonld` — JSON-LD structured data | Essential | Critical | — |
| `faq-schema` — FAQ / question-answer schema | Recommended | High | — |
| `breadcrumb` — Breadcrumb / navigation schema | Emerging | Low | — |
| `summary` — Prominent summary block | Recommended | Medium | — |
| `lang` — Language declaration and multilingual access | Recommended | Medium | — |
