Performance: Environment configuration
MEDIUM IMPACT
This affects the startup time and memory usage of Node.js applications by controlling how environment variables and configuration files are loaded.
if (process.env.NODE_ENV !== 'production') { require('dotenv').config({ path: './small-config.env' }); } // load only small dev config
require('dotenv').config({ path: './large-config.env' }); // large file with many variables loaded synchronously
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous .env load with large file | N/A | N/A | N/A | [X] Bad |
| Conditional small .env load | N/A | N/A | N/A | [OK] Good |
| Repeated process.env access in loops | N/A | N/A | N/A | [X] Bad |
| Cached environment variables | N/A | N/A | N/A | [OK] Good |
| Synchronous JSON config read | N/A | N/A | N/A | [X] Bad |
| Native JSON import or async read | N/A | N/A | N/A | [OK] Good |