UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

41 lines (28 loc) โ€ข 1.15 kB
### ๐Ÿš€ What's New ### ๐Ÿ•’ `TinyDomReadyManager` A flexible DOM readiness manager built to go beyond `DOMContentLoaded`! #### โœ… Key Features: * ๐Ÿ” **Callback queue** with `priority`, `once`, and `filter` support * โœจ **`domOnly` mode** to execute handlers immediately after the DOM is ready, skipping async waits * โณ **Promise integration** โ€” delays full readiness until all custom promises resolve * ๐Ÿง  **Safe execution**, with internal try-catch for all filters and handlers * ๐Ÿ” New `isReady()` and `isDomReady()` public methods to track current readiness state #### ๐Ÿ“˜ Usage Example: ```js manager.onReady(() => { console.log('DOM-only logic!'); }, { domOnly: true, priority: 10 }); manager.onReady(() => { console.log('Waits for external API...'); }); manager.addPromise(fetch('/api')); manager.init(); ``` --- ### ๐Ÿงช Internal Notes * Handlers are sorted by priority * `domOnly: true` handlers always run first * The system is considered fully ready only after: * DOMContentLoaded * All added promises resolved **Full Changelog**: https://github.com/JasminDreasond/Tiny-Essentials/compare/1.12.2...1.13.0