Detect element availability on the initial page load and those dynamically appended to the DOM
JavaScript HTML
Latest commit 6672619 May 11, 2016 @ryanmorr Update build
Permalink
Failed to load latest commit information.
dist
src
test
.editorconfig
.gitattributes
.gitignore
.jshintrc
.travis.yml
README.md
UNLICENSE
gulpfile.js
package.json

README.md

ready Build Status

Watch for specific element availability on initial page load as well as dynamically appended elements via mutation observers. Please refer to the blog post to read more.

Usage

Provide a selector string for the element(s) you want to target as the first argument and the callback function as the second argument:

ready('.foo', function(element){
    // do something
});

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 available, the callback is invoked in succession for each element in document order.

Browser Support

  • Chrome 18*
  • Firefox 14*
  • Opera 15+
  • Safari 6+
  • Internet Explorer 11+
  • Android 4.4+
  • iOS 7.1*

Installation

Ready is CommonJS and AMD compatible with no dependencies. You can download the development or minified version, or install it in one of the following ways:

npm install git+https://git@github.com/ryanmorr/ready.git

bower install ryanmorr/ready

Tests

Open test/runner.html in your browser or test with PhantomJS by issuing the following commands:

npm install
npm install -g gulp
gulp test

License

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