What I Learned Shipping Offline-First Habit Timers With Zero Dependencies
I build small browser games and habit tools in plain JavaScript. No bundler, no framework, no package install. Here is what that constraint actually taught me while shipping a habit timer that works offline. Wh
I build small browser games and habit tools in plain JavaScript. No bundler, no framework, no package install. Here is what that constraint actually taught me while shipping a habit timer that works offline.
Why zero dependencies was not a style choice
The app is a PWA that people open on a phone, often on bad mobile data. Every dependency I add is another file to cache, another cache-busting rule to maintain, and another thing that can break when the network drops mid-update.
So the stack is ES5 plus a single global namespace. Persistence is localStorage for state and IndexedDB for binary blobs. Service worker handles offline. That is the whole architecture.
The three tradeoffs I actually had to make
1. Big numbers need their own formatter early. Rewards compound through daily check-ins and game scores. When the values crossed ten thousand, the UI broke visually. I added one number formatter (wan / yi / zhao / jing) and applied it everywhere. Doing this late cost more than writing it on day one.
2. Deep-page translation has an ordering trap. A dictionary-based i18n layer works until a rule for a nested page is matched by a broader game rule first. The fix was ordering: deep-page rules before game rules, then translate attributes separately, then skip contenteditable and anything marked no-i18n. Order matters more than dictionary size.
3. Stale cache is worse than no cache. After each release, some users kept the old interface because the old service worker stripped the version query string and served an old cached file. The fix was to clear the search string before fetch, reload once on controller change, and block a reload loop with a short session guard. This is the kind of bug that never shows up in local tests.
What surprised me
The hardest part was not rendering or game logic. It was making two mini-games share one card deck source and one sound catalog without either game depending on the other's module. I ended up with a small shared data provider and a rule that each game owns only its own state.
I also stopped showing every number. Sharing counts and click counts looked impressive in the admin view but added nothing for the person using the app. Removing them made the interface calmer.
Where it stands
Life Timer is in a 14-day closed beta. Open it daily for 14 days, then you can claim a free lifetime pass when it launches. No review or survey required. I am the developer, so treat this as a build note, not a neutral review.
Opt in: https://life-timer-test.surge.sh/?utm_source=devto_article2
If you ship offline-first tools, which part gave you the most trouble: cache invalidation, storage limits, or state sync? I am curious which one others hit first.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.