Skip to content

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

License

Notifications You must be signed in to change notification settings

michealparks/document-ready-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published