- Status changed to Needs review
about 1 year ago 6:55pm 5 September 2024 - π¨πΎCyprus alex.bukach
I have reworked the module to use JavaScript for counting so that the blocks can now be safely cached.
@alex.bukach, I tested your MR in a sandbox with drupal/countdown 8.x-1.10 and Drupal 10.2.8 and Drupal 11.0.4. The timer now counts down as expected. I see the seconds and minutes changing in real time. I will plan to test it more properly and report back.
- Assigned to mahyarss
- Status changed to Fixed
9 days ago 12:06am 28 August 2025 - π΅π±Poland mahyarss
This highly requested feature has been fully implemented in the 8.x-1.11 major refactor, exceeding the original requirements with a comprehensive solution.
What's been implemented:
- Real-time JavaScript countdown - The core request, now reality
- Dual-mode rendering system:
- Static mode: Server-side (preserves backward compatibility)
- Real-time mode: Client-side JavaScript countdown
- CountdownTimer library features:
- Configurable precision (minutes, seconds, tenths, hundredths, milliseconds)
- Drift compensation for long-running accuracy
- Auto-start on page load
- Pause/resume/stop/reset controls
- Event-driven architecture
- Display formats:
- Default (HH:MM:SS)
- Verbose (3 days, 2 hours, 1 minute)
- Compact (3d 2h 1m)
- Custom templates with tokens
- Advanced features:
- Completion actions (hide, message, redirect, reload, elapsed mode)
- Timezone support
- JavaScript API for programmatic control
- Count up mode (elapsed time)
Technical details:
// New vanilla JavaScript implementation const timer = new CountdownTimer({ selector: '#countdown-display', mode: 'countdown', precision: 'seconds', autoStart: true, driftCompensation: true }); // Full API available Drupal.countdown.controlTimer(blockId, 'start|pause|resume|stop|reset');
How to enable:
- Update to 8.x-1.11
- Edit your countdown block
- Change "Render Mode" to "Real-time JavaScript countdown"
- Configure precision and display options as needed
Download: https://www.drupal.org/project/countdown/releases/8.x-1.11 β
Thank you to everyone who contributed ideas and patches over the years. Your patience has resulted in a robust, modern implementation!
- π΅π±Poland mahyarss
Fixed in: 8.x-1.11
Feature request completed after 14 years!
Original request (2010):
"Add option to count down in real time using Javascript"
What we delivered (2024):
Not just a simple JavaScript countdown, but a complete real-time countdown system with modern architecture:
- Pure Vanilla JavaScript - No jQuery dependency
- ES6 Modern Architecture - IIFE/UMD pattern
- Zero External Dependencies - Lightweight (~2KB gzipped)
- Drift Compensation Algorithm - Maintains accuracy over days/weeks
- Multiple Update Frequencies - From minutes to milliseconds
- Full Drupal Integration - Works with Drupal 8/9/10/11
Beyond the original request:
The implementation includes features that weren't even imagined in 2010:
- WeakMap memory management
- Event-driven architecture with custom events
- Programmatic JavaScript API
- Multiple display formats and custom templates
- Completion actions and elapsed time mode
- Debug mode for development
Performance metrics:
- Size: ~2KB gzipped
- CPU: < 0.1% usage
- Memory: Efficient WeakMap prevents leaks
- Accuracy: Drift compensation maintains precision
Credits:
Thanks to all 50+ contributors who participated in this issue over the years. Special recognition to early contributors whose ideas shaped the final implementation.
The wait is over. Real-time JavaScript countdown is not just hereβit's better than we ever imagined!
For any issues with the new implementation, please open a new issue. This long-standing feature request is now officially closed.