document-ready-promise

3.0.1 • Public • Published

document-ready-promise

A simple promise-compatible "document ready" event handler with a few extra treats.

Works in any browser that supports Promises or with a good polyfill.

With browserify/webpack:

const ready = require('document-ready-promise')
 
ready().then(function() {
  // Party time.
})
 

If in a non-commonjs environment, just include the script. It will attach document.ready for you.

<script src="document-ready-promise.js"></script>
<script>
document.ready().then(function() {
  // voila!
})
</script> 

The document.ready promise will preserve any values that you may be passing through the promise chain.

// Using ES2015 and window.fetch
fetch(new Request('kitten.jpg'))
  .then(response => response.blob())
  .then(document.ready)
  .then(blob => document.querySelector('img').src = URL.createObjectURL(blob))

Package Sidebar

Install

npm i document-ready-promise

Weekly Downloads

834

Version

3.0.1

License

MIT

Last publish

Collaborators

  • micheal.parks