Performance: Environment variables on Deploy
This concept affects page load speed by controlling how configuration data is injected without increasing bundle size or blocking rendering.
const API_KEY = Deno.env.get("API_KEY") ?? ""; // Environment variable injected at deploy, not bundled
const API_KEY = "hardcoded_api_key"; // API key is bundled directly in client code
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Hardcoded secrets in bundle | Minimal | 0 | High due to large bundle parse | [X] Bad |
| Environment variables injected at deploy | Minimal | 0 | Low due to smaller bundle | [OK] Good |
API_KEY in a Deno script?Deno.env.get("NAME") to access environment variables.PORT=8080, what will be the output?const port = Deno.env.get("PORT") || "3000";
console.log(`Server running on port ${port}`);Deno.env.get("PORT") || "3000", so it uses "8080" because PORT exists.undefined. Which fix will solve this problem?Deno.env.get can read them.MODE to switch between 'development' and 'production'. Which approach correctly uses environment variables to change app behavior safely?MODE in deployment and reading it with Deno.env.get enables safe conditional logic.Pass the test and this pattern moves unknown