Performance: Streaming responses
MEDIUM IMPACT
Streaming responses impact how quickly users see partial data and how smoothly the UI updates during data loading.
const stream = await chain.stream({ input: 'query' }); for await (const chunk of stream) { console.log(chunk.text); }
const response = await chain.invoke({ input: 'query' }); console.log(response.text);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full response wait | Single large DOM update | 1 reflow after full data | High paint cost at once | [X] Bad |
| Streaming response | Multiple small DOM updates | Multiple small reflows | Lower paint cost per update | [OK] Good |