All Projects → ryanmorr → ready

ryanmorr / ready

Licence: Unlicense license
Detect element availability on the initial page load and those dynamically appended to the DOM

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ready

Nanohtml
🐉 HTML template strings for the Browser with support for Server Side Rendering in Node.
Stars: ✭ 651 (+745.45%)
Mutual labels:  dom, element
Elementx
⚡️ Functionally create DOM elements and compose them to a tree quickly
Stars: ✭ 62 (-19.48%)
Mutual labels:  dom, element
Resize Observer
Polyfills the ResizeObserver API.
Stars: ✭ 540 (+601.3%)
Mutual labels:  observer, element
Web-Map-Custom-Element
A custom <mapml-viewer> and <layer-> element suite
Stars: ✭ 49 (-36.36%)
Mutual labels:  dom
html5parser
A super tiny and fast html5 AST parser.
Stars: ✭ 153 (+98.7%)
Mutual labels:  dom
render-props
㸚 Easy-to-use React state containers which utilize the render props (function as child) pattern
Stars: ✭ 33 (-57.14%)
Mutual labels:  dom
vanilla-caret-js
Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript
Stars: ✭ 31 (-59.74%)
Mutual labels:  dom
hast-util-from-dom
utility to transform a DOM tree to hast
Stars: ✭ 20 (-74.03%)
Mutual labels:  dom
playwright-demos
playwright for scrapping and UI testing / automate testing workflows
Stars: ✭ 65 (-15.58%)
Mutual labels:  dom
vue-drag-select
A Vue component for drag selecting elements. Inspired by react-drag-select.
Stars: ✭ 73 (-5.19%)
Mutual labels:  dom
glimmer-dsl-opal
Glimmer DSL for Opal (Pure-Ruby Web GUI and Auto-Webifier of Desktop Apps)
Stars: ✭ 22 (-71.43%)
Mutual labels:  dom
aurum
Fast and concise declarative DOM rendering library for javascript
Stars: ✭ 17 (-77.92%)
Mutual labels:  dom
rehype-dom
HTML processor to parse and compile with browser APIs, powered by plugins
Stars: ✭ 20 (-74.03%)
Mutual labels:  dom
InDiv
an angular like web mvvm framework.一个类 angular 前端框架。https://dimalilongji.github.io/InDiv
Stars: ✭ 88 (+14.29%)
Mutual labels:  dom
dom
Package for access and manipulate DOM element in HTML file
Stars: ✭ 29 (-62.34%)
Mutual labels:  dom
vue-next-admin
🎉🎉🔥基于vue3.x 、Typescript、vite、Element plus等,适配手机、平板、pc 的后台开源免费模板库(vue2.x请切换vue-prev-admin分支)
Stars: ✭ 1,002 (+1201.3%)
Mutual labels:  element
minimalist
Observable Property and Signal for building data-driven UI without Rx
Stars: ✭ 88 (+14.29%)
Mutual labels:  observer
bs-declaredom
Strongly typed declarative markup for the DOM and CSS
Stars: ✭ 66 (-14.29%)
Mutual labels:  dom
angular-datetime-inputs
📅 Angular directives for datetime inputs
Stars: ✭ 20 (-74.03%)
Mutual labels:  element
necktie
Necktie – a simple DOM binding tool
Stars: ✭ 43 (-44.16%)
Mutual labels:  dom

ready

Version Badge Build Status License

Detect element availability on the initial page load and those dynamically appended to the DOM

Install

Download the CJS, ESM, UMD versions or install via NPM:

npm install @ryanmorr/ready

Usage

Provide a selector string for the element(s) you want to target as the first argument and a callback function as the second argument. It returns a function that stops observing for new elements only for that particular selector/callback combination:

const off = ready('.foo', (element) => {
    off(); // Stop observing for ".foo" elements
});

When any element matching the selector becomes available, the callback is invoked in the context of the element as well as passing it as the only parameter. If multiple elements are found, the callback is invoked in succession for each element in document order.

Alternatively, provide just the callback function as the only argument to add a generic DOM ready event listener:

ready((doc) => {
    // The DOM is ready
});

License

This project is dedicated to the public domain as described by the Unlicense.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].