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
Markdown
### ๐ 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