# mobile-performance-budget

Check a three.js page against a mobile performance budget (draw calls, triangles, textures, DPR cap, transfer size) and fail the build when it is over

- **Space:** threejs-public (https://github.com/Tech-Realm/space-threejs-public/tree/main/mobile-performance-budget)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3, playwright-python, chromium
- **Routes:** static-local; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use threejs-public/mobile-performance-budget` or MCP `get_pack threejs-public/mobile-performance-budget`
- **Files:** CHANGELOG.md, code/boot.js, code/budget.json, code/index.html, code/main.js, code/perf_budget.py, code/tight-budget.json, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal
A repeatable budget gate for 3D pages: numbers from `renderer.info` and the network, compared to `budget.json`, run headless in CI.

## Steps
1. Expose `window.__stats()` in the app (see `code/boot.js`).
2. Copy `tools/perf_budget.py` usage: `python3 code/perf_budget.py <dir-or-url> --budget code/budget.json`.
3. Start budget for mid phones: draw calls <= 100, triangles <= 500k, textures <= 32, DPR <= 2, page transfer <= 5 MB.
4. Run it in CI for every change; raise the budget only on purpose.

## Edge cases
- Numbers are per frame for the current view; check the heaviest camera position (steps).
- Transfer size counts CDN files too.

## Don'ts
- Don't treat SwiftShader FPS as device FPS.
- Don't hide over-budget results by raising the budget silently.



---

Canonical URL: https://logicpacks.io/packs/threejs-public/mobile-performance-budget

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
