Skip to content

Advanced JavaScript library for managing time-based DOM elements with timezone support, callbacks, and performance optimizations

License

Notifications You must be signed in to change notification settings

morkevicius/timestamp-witch-js

Repository files navigation

TimestampWitchJs

npm version License: MIT

Advanced library for managing HTML elements based on timestamps with timezone support.

Features

  • Remove elements based on expiry timestamps with flexible format support
  • Pre-scheduling of removals for efficiency
  • Multiple timezone support (UTC, local, or specific timezones)
  • JavaScript and HTTP callbacks on element removal
  • Lazy loading with IntersectionObserver
  • Worker thread processing for performance
  • Intelligent rescanning with MutationObserver
  • Local storage caching for persistence
  • Debug mode for development
  • Batched DOM updates for smooth UI
  • Throttled removals

Installation

npm install timestamp-witch-js

Basic Usage

// Initialize with default settings
const witch = new TimestampWitchJs().init();

// Add expiry to an element
witch.addExpiryToElement(document.querySelector('.my-element'), '2025-04-04 09:30:00 UTC');

HTML Markup

<div class="match-card" 
     data-tc-expiry="2025-04-04 09:30:00"
     data-tc-timezone="America/New_York"
     data-tc-callbackFunction="updateCounter">
  Time-sensitive content
</div>

Advanced Configuration

See the full documentation for details on all configuration options and features.

Credits

Original idea by Saulius Morkevicius
Generated with the assistance of Claude 3.7 Sonnet

License

MIT

About

Advanced JavaScript library for managing time-based DOM elements with timezone support, callbacks, and performance optimizations

Resources

License

Stars

Watchers

Forks

Packages

No packages published