Performance: Handling environment variables
MEDIUM IMPACT
This affects page load speed and bundle size by controlling which environment variables are exposed to client-side code.
const apiKey = import.meta.env.PUBLIC_API_KEY; // Only variables prefixed with PUBLIC_ are exposed to client console.log(apiKey);
const apiKey = import.meta.env.PUBLIC_API_KEY; // Using PUBLIC_ prefix for unnecessary or sensitive vars in client-side code console.log(apiKey);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Exposing unnecessary env vars client-side | N/A | 0 | Increased due to larger JS | [X] Bad |
| Exposing only PUBLIC_ prefixed vars | N/A | 0 | Minimal JS size impact | [OK] Good |