Pagination StrategyWhich pagination strategy handles a live feed receiving new posts cleanly?Cursor PaginationRecommendedOffset PaginationProsZero duplicate or skipped posts when new items insert at top of timeline.O(1) indexed DB seeks using opaque `(createdAt, id)` cursor.Cons & PitfallsCannot jump directly to "Page 7" arbitrarily.Interview Rule of Thumb: Pick Cursor Pagination for every live infinite feed (X, Instagram, LinkedIn).
List DOM RenderingHow should 1,000+ scrolled posts be managed in browser DOM?Windowed / Virtualized ListRecommendedAppend All DOM NodesProsKeeps DOM node count constant (~20 cards) regardless of how far user scrolls.Eliminates janky layouts and browser tab OOM crashes on mobile.Cons & PitfallsRequires measured or estimated item heights for variable-height cards.Interview Rule of Thumb: Pick Virtualization whenever feeds scroll unbounded (social, logs, chat).
RRequirements & Scope Defined MVP scope + 60fps & zero-CLS performance budgets Functional: Text/image/video feed, infinite scroll, optimistic like/bookmark, pull-to-refresh.Non-Functional: Initial feed painted < 1.5s, 60fps scroll, zero CLS, mobile-first memory cap.
AArchitecture Components Separated normalized store, observer trigger & virtual scroller Normalized Store (`postsById`, `usersById`) separated from view-specific `feedOrder[]`.IntersectionObserver trigger decouples scroll detection from manual `onscroll` throttling.Virtual Scroller / Dynamic Height Cache keeps off-screen posts out of active DOM.
DClient Data Model Designed normalized Post/Author entities with aspect ratios `FeedState: { ids: string[], nextCursor: string | null, status: "idle"|"loading" }``PostEntity: { id, authorId, text, mediaUrl, aspectRatio, likeCount, likedByMe }`Dedup `Set<string>` guarantees identical IDs never render twice on screen.
IInterface & API Contracts Specified cursor API contract & optimistic rollback flow `GET /api/v1/feed?cursor=eyJ0cyI6MTcwMH0&limit=15` -> `{ items, nextCursor, hasMore }``POST /api/v1/posts/:id/like` -> `{ likeCount, likedByMe }` (reconciles optimistic UI).
OPerformance & Optimizations Covered video auto-pause, prefetching & responsive media CDN Auto-pause offscreen `<video>` elements via IntersectionObserver to save CPU/battery.Reserve media space with `aspect-ratio` + `loading="lazy"` + responsive `srcset`.Prefetch `N+1` cursor silently at 70% viewport depth so user never waits for spinner.