# Your app's gigabytes: measure, rank, cut

You are helping me reduce how many bytes my app sends to users, without making it worse. Read my project first (framework, hosting/CDN, where images, video and files are stored, API layer). Work in three phases and wait for my OK before changing code.

## A. Measure (read only)
1. **Where the bytes go:** from my host/CDN analytics or logs, list bandwidth for the last 30 days by route or file type (HTML, JS, CSS, images, video, fonts, API, downloads). If there are no analytics, estimate from a production build and the 10 most visited pages.
2. **Heaviest pages:** for the 5–10 most visited pages, total transfer size on first load and on repeat visits (cache warm), and the 10 largest requests on each.
3. **Per country, if available:** what share of traffic goes to France and the EU (relevant if the French per-gigabyte levy becomes law; check its current status first, it may change).

## B. Rank
4. Make a table: item, bytes per month, why it's heavy, proposed fix, estimated saving, risk. Sort by saving.

## C. Cut (one change at a time, with my OK)
5. **Images:** serve AVIF/WebP with a fallback, responsive `srcset`/sizes, correct dimensions, lazy-load below the fold, strip metadata.
6. **Video:** never autoplay full-resolution files; use a streaming format with adaptive bitrate (HLS/DASH) or a video host, a poster image, and `preload="none"` or `metadata`.
7. **JavaScript and CSS:** code-split by route, drop unused dependencies, tree-shake, minify, and check the bundle analyzer for the biggest modules.
8. **Fonts:** subset to the characters you use, WOFF2 only, at most 2–3 files, `font-display: swap`.
9. **Compression:** Brotli (or gzip) for text responses at the CDN; confirm with response headers.
10. **Caching:** long `Cache-Control` with hashed filenames for static assets, sensible caching for HTML and API responses, ETags so repeat visits download nothing that didn't change.
11. **API payloads:** paginate, return only the fields the screen uses, compress JSON, avoid polling (use push or longer intervals).
12. **Downloads and media storage:** serve user uploads through the CDN, resize on upload, delete or archive what nobody opens.

After each change, re-measure the same pages and show the before/after bytes. Don't change behaviour users can see without telling me first.
