About this set
Counters that keep changing while the page is open. Running total ticks a large figure upwards at a set rate, such as meals served since 2009 at about three a second. Goal with a countdown shows money raised against a target with a progress bar, the amount still to raise and a days, hours, minutes and seconds countdown to the closing date. Since you opened this page starts at 0 and counts trees planted while the visitor reads. The HTML holds each value at page load, so it is still true without JavaScript. A short vanilla script works every value out from the clock and a data-rate per second, so numbers are right again after any pause rather than drifting. Updates stop while a card is off-screen, using IntersectionObserver, and while the tab is hidden, and each card has a Pause updates button. Use a real start time with data-ends on the countdown and feed data-rate from your own figures.
What’s included
- Running total, goal with countdown, and since-you-arrived counter
- Values calculated from the clock, so they stay correct after a pause
- Updates stop when the card is off-screen or the tab is hidden
- Pause updates button on every card
- Countdown takes data-seconds or a data-ends date
Accessibility
Each card has a Pause updates button, so the moving numbers can be stopped as WCAG 2.2.2 asks; it shows a focus outline and its label changes to Resume updates. The numbers update in place with no animation, the countdown has role timer, and none of them is a live region, so screen readers are not interrupted every second. Without JavaScript the buttons stay hidden and the status reads As of page load instead of Live. The pulsing dot stops under prefers-reduced-motion.
Customise it
Set data-rate (units per second) and data-goal on each [data-live] card, and data-seconds or data-ends on the countdown. Colours are --lv-accent, --lv-accent-2 and --lv-soft on .lv; in Bootstrap the button is .btn restyled through --bs-btn-* variables, and in Tailwind edit the --color-lv-* theme colours.






