Performance: Passport.js integration
MEDIUM IMPACT
This affects the server response time and initial page load speed by adding authentication middleware processing.
app.use(passport.initialize()); // Use session only if needed // Load strategies lazily or conditionally passport.use('local', new LocalStrategy(...)); // Apply JWT strategy only on protected routes
app.use(passport.initialize()); app.use(passport.session()); // Using multiple heavy strategies without lazy loading passport.use('local', new LocalStrategy(...)); passport.use('jwt', new JwtStrategy(...));
| Pattern | Middleware Overhead | Server Response Delay | User Interaction Impact | Verdict |
|---|---|---|---|---|
| Eagerly load all Passport strategies and session middleware | High (multiple strategies active) | Adds 20-50ms delay | Slower input responsiveness (INP) | [X] Bad |
| Initialize Passport with minimal strategies and no session middleware unless needed | Low (only required strategies) | Adds 5-10ms delay | Better input responsiveness (INP) | [OK] Good |