What is domready?
The domready npm package is a lightweight utility that allows you to execute a function when the DOM is fully loaded. It is particularly useful for ensuring that your JavaScript code runs only after the HTML document has been completely parsed.
What are domready's main functionalities?
Execute a function when the DOM is ready
This feature allows you to pass a callback function that will be executed once the DOM is fully loaded. It ensures that your code runs at the appropriate time, avoiding issues related to elements not being available in the DOM.
require('domready')(function () {
console.log('DOM is ready!');
});
Other packages similar to domready
dom-loaded
The dom-loaded package provides similar functionality by allowing you to execute a function when the DOM is fully loaded. It offers a promise-based API, which can be more convenient for modern JavaScript development. Unlike domready, dom-loaded returns a promise that resolves when the DOM is ready.
document-ready
The document-ready package is another alternative that provides a simple way to execute a function when the DOM is ready. It is similar to domready but offers a slightly different API. It is also lightweight and easy to use.
ready
The ready package is a small utility that allows you to run a function when the DOM is ready. It is similar to domready but provides additional features such as checking if the DOM is already loaded before executing the callback.
domReady
It's easy. Works like this:
domready(function () {
})
Deprecation Notice
Compatibility with IE6
, IE7
, and IE8
has been fully dropped. If your application requires this level of support, please use the 0.3.0
release.
Browser support
- IE9+
- Firefox 4+
- Safari 3+
- Chrome *
- Opera *
Building
npm install
make
open tests/test.html
Including with Ender
Don't already have Ender? Install it like this:
npm install ender -g
Include domready in your package:
ender add domready
Then use it like this
require('domready')(function () {
$('body').html('<p>boosh</p>')
})
$(document).ready(function () {
$('body').html('<p>boosh</p>')
})