performance
Technical notes on web development, DevOps, and AI integration.
8 articles
- 00:40frontend
Deep-Link Video in Mega Menu: URL, State, Preload Done Right
Three URL layers for mega menu video deep-links: path for identity, query for panel state, hash for timestamp. Manual sync of video.currentTime to hash. Preload metadata + poster, not auto. Prefetch route on hover, not auto.
TL;DR: Use path segments for video identity, query strings for panel state, and hash fragments for timestamps to create bookmarkable URLs. React Activity preserves component state but not video playback, so manually sync currentTime with the hash on mount and timeupdate. For mega panels, set preload="metadata" with posters and manually prefetch on hover since hidden elements skip automatic prefetching.
#frontend#performance#nextjs - 00:44frontend
Why Popular Video Cards Have No Thumbnails
Popular marquee cards checked explicit thumbnails, leaving video items on gradients. Fix: explicit thumbnail → i.ytimg hqdefault → gradient. hqdefault always exists for public videos.
TL;DR: Video items showed a gradient placeholder. A fallback chain was added to display thumbnails. It uses YouTube's image CDN for video thumbnails.
#frontend#performance#nextjs - 00:36frontend
Why the "Popular" Marquee Across Three Pillars Looks Empty — and How to Fill It
Marquee populer 3 pilar (olahraga/kebudayaan/kepemudaan) kosong di pilar muda. Fix: parallel fetch popular + random, mergePopularWithRandom dedupe by id, popular priority, slice 9.
TL;DR: KotaPortal's marquee looked half-empty. Server-side parallel fetch and merge dedupe fixed this. Young pillars now display 9 items.
#frontend#performance#nextjs - 00:28backend
Why "Popular Articles" Stay Stale — and How to Fix It with a 7-Day Rolling Score
Query sort=popular used total view_count so old articles always won. Fix: 7-day rolling score from entity_view_daily + deterministic tiebreak + random filler limit 9.
TL;DR: The "Popular Articles" section showed outdated items. A 7-day rolling score was implemented to fix this. Old articles no longer always rank highest.
#database#performance#mysql - 10:26frontend
Four Commits, One Flag: When the Image Optimizer Is the Bug
Flat-color artwork turned muddy by the default WebP quality-75 pipeline: a single unoptimized flag served the original file untouched.
TL;DR: The Next.js Image component's default lossy WebP pipeline at quality 75 wrecked flat-color mascot artwork, adding fat edges and banding the pristine PNG never had. Instead of touching global config, the fix was one unoptimized prop on that single hero slot; the 170 KB file is small enough that skipping optimization costs little. Photos stay optimized.
#nextjs#next-image#webp - 05:16frontend
The sizes Hint Lies Once a CSS Max-Width Clamps in Next.js
A CSS max-width clamp ships, but the vw sizes hint keeps promising a bigger slot. Make the contract honest with pixel values so srcset picks right.
TL;DR: Clamping an oversized hero image with CSS max-width looks fixed visually, but the browser still downloads a huge file. The culprit was a stale sizes attribute promising 40vw, so the browser picked a 576px srcset candidate for a 330px box. Honest pixel values in sizes, matched to the breakpoint clamp, keep downloads lean.
#nextjs#next-image#css - 22:22frontend
Splitting a Giant Logo Wall into 113 Clean Tiles
How I cut one client-logo wall raster into 113 uniform tiles: whitespace segmentation, a 220x130 canvas, and a stable next/image grid.
TL;DR: A single giant client-logo raster gets split deterministically using whitespace projection and connected components, no machine learning needed. Each crop is normalized onto a 220x130 white canvas so the grid stays tidy without stretching. The frontend uses next/image with explicit dimensions, lazy loading, and slot-based naming to prevent layout shift and keep pruning safe.
#nextjs#next-image#performance - 17:27backend
Not Just SQL: When API Fan-out Kills Your Monitor
Fixing an N+1 API fan-out in commitcheck: one pagination pass replaces 250 requests, SSL timeout gone, runtime down to 27.5s.
TL;DR: The monitor hung for over 100 seconds because each candidate triggered full pagination, creating roughly 250 requests per run. Replacing per-candidate checks with a single paginated fetch into a commit-to-slug map removed the N+1 overhead. Runtime dropped to 27.5 seconds with only a few requests and no change to the API contract.
#pagination#performance#api