Performance: Swagger API documentation
MEDIUM IMPACT
This affects the initial page load speed and bundle size by adding metadata and UI assets for API docs.
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; const config = new DocumentBuilder() .setTitle('API') .setDescription('API docs') .setVersion('1.0') .build(); const document = SwaggerModule.createDocument(app, config); if (process.env.NODE_ENV === 'development') { SwaggerModule.setup('api', app, document); }
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; const config = new DocumentBuilder() .setTitle('API') .setDescription('API docs') .setVersion('1.0') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full Swagger UI always loaded | High (many UI nodes) | Multiple reflows on load | High paint cost due to UI | [X] Bad |
| Swagger UI loaded only in development | Low (no UI in prod) | No reflows in prod | Minimal paint cost in prod | [OK] Good |