How I Cut 40KB from My Edge Bundle with Zero-Dep Utils
Description and use
Reduced Cloudflare Workers bundle size from ~40 KB to ~2 KB by replacing heavy dependencies with zero‑dependency utilities, improving cold starts and staying within limits.
Problem
Large bundle size in Cloudflare Workers caused cold start delays and exceeded free tier limits.
Outcome
Reduced bundle size from ~40 KB to ~2 KB, a 95 % reduction, eliminating large dependencies and container usage.
Workflow
- Identify utilities inflating bundle size.
- Select or build zero‑dependency replacements.
- Integrate fetch-retry-jitter for retry logic.
- Integrate env-assert-typed for environment validation.
- Replace tj-actions/changed-files with ci-diff-changed in GitHub Actions.
- Measure bundle size before and after.
- Publish results and provide starter templates.
Evidence
Every "lightweight" utility pulled in dependencies. zod (1.1 MB), p-retry (7 KB + deps), axios-retry (requires axios).
fetch-retry-jitter (1.6 KB gzip)
env-assert-typed (528 B gzip)
ci-diff-changed (Action, ~80 lines bash)
Total bundle reduction: ~40 KB → ~2 KB (95% reduction)
- Record date: 2026-11-01T08:14:18.769Z