Performance: Environment variables ($env)
MEDIUM IMPACT
This affects page load speed and bundle size by controlling which environment variables are included in the client bundle.
import { PUBLIC_API_URL } from '$env/static/public'; console.log(PUBLIC_API_URL);
import { env } from '$env/dynamic/public'; console.log(env);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Dynamic import of all env vars | Minimal | 0 | Low but delayed due to JS parsing | [X] Bad |
| Static import of specific env vars | Minimal | 0 | Low and fast | [OK] Good |