FlashcardNot attempted
Design a news feed
Recall it before you reveal
Design an infinite-scrolling news feed (Facebook/Twitter style).
Space to reveal
Show answer & explanation
- Requirements: infinite scroll, mixed post types (text, image, video), likes and comments, new-post indicator, fast first paint, works on low-end phones.
- Rendering: SSR or streamed first page for fast LCP, then client-side pagination.
- Data: normalized posts/users; cursor pagination; server-state cache.
- Loading:
IntersectionObserversentinel to fetch the next page; virtualise the list (only render what's on screen); lazy-load images with reserved dimensions (no CLS). - Real-time: SSE/WebSocket or polling for a "N new posts" banner, so content never jumps under the user's finger.
- Interactions: optimistic likes; comments loaded on demand.
- Other: preserve scroll position on back-navigation; a11y (
role="feed",aria-busy).