For the best experience on desktop, install the Chrome extension to track your reading on news.ycombinator.com
Hacker Newsnew | past | comments | ask | show | jobs | submit | history | Shawn1991's commentsregister

For those who enjoy some technical details:

To make this runnable 24/7 on an old device without turning it into a hand-warmer. This meant focusing heavily on performance and efficiency.

The core idea was to separate static content from dynamic content to avoid unnecessary, expensive redraws on every frame. Here’s how I approached it:

This meant moving beyond simple CSS animations and focusing on a more optimized rendering approach.

Here's what I did:

- Off-Screen Canvas: Instead of manipulating DOM elements directly for each animation tick, I use an off-screen canvas to pre-render the state of the clock digits. This avoids triggering constant, expensive layout shifts and repaints on the main page, making the animation much smoother.

- Event-Driven Rendering: The clock doesn't just redraw on every requestAnimationFrame. It's smarter than that. I implemented an event-driven model where the rendering logic only triggers when a digit actually needs to change (i.e., once per second for the seconds, once per minute for the minutes, etc.).

This decoupling of rendering from the animation frame rate saves a surprising amount of CPU cycles, which is crucial for older devices.


The extension is still in its infancy. All critiques or suggestions are welcome.


thanks. really appreciated


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

HN For You