The Hidden Bug Breaking Most JavaScript Timers

https://hackernoon.imgix.net/images/SjcvKH984mTDwww0NPX6gB9ilyt2-wi83h2d.png

If you've ever set a 5-minute timer in a browser tab, switched to another tab, and come back to find the alarm fired at 5:08 instead of 5:00, or didn't fire at all, you've hit one of the most underdiagnosed bugs in client-side timing. The fix isn't in your timer logic. It's in scheduling the alarm itself.

I ran into this building Timerjoy, a static Next.js site with 1,400+ timer pages. The naive version of my 25-minute timer worked perfectly in foreground tabs and missed by 5 to 30 seconds in backgrounded tabs. Here is the actual mechanism, the diagnostic data, and the two-layer fix that brought drift to under 50 milliseconds regardless of tab state.

The textbook timer (and why it fails)

The way most tutorials teach a JavaScript countdown:

function startTimer(durationMs, onTick, onComplete) { let remaining = durationMs const interval = setInterval(() => { remaining -= 1000...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more

https://www.engadget.com/img/gallery/amd-prices-its-ryzen-ai-halo-pc-at-3999-unveils-ryzen-ai-max-400-chips/l-intro-1779288878.jpg

AMD says its Mac Mini-sized Ryzen AI Halo PC starts at $3,999 with Ryzen AI Max 300 chips, for pre-order in June, and unveils AI Max 400 chips, available in Q3

Sponsor Posts Niantic Spatial: World models need real-world data — Scaniverse is the gateway to spatial services — self-serve and built for AI and robotics. Large-area 3D reconstruction from 360° cameras and precise localization, anywhere machines operate. App Spotlight: Quo for Zoho CRM — App Spotlight brings you hand-picked solutions that enhance your

https://images.ctfassets.net/jdtwqhzvc2n1/2ooDwZZRkOXFbljlU3UX8T/512fe2501fcc0281a48bc484e7794a7f/ChatGPT_Image_May_20__2026__03_40_32_PM.png?w=800&q=75

Cohere releases Command A+, a sparse MoE open model built for agentic tasks, with 218B total and 25B active parameters, its first under the Apache 2.0 license

Sponsor Posts Niantic Spatial: World models need real-world data — Scaniverse is the gateway to spatial services — self-serve and built for AI and robotics. Large-area 3D reconstruction from 360° cameras and precise localization, anywhere machines operate. App Spotlight: Quo for Zoho CRM — App Spotlight brings you hand-picked solutions that enhance your