@grrr/ready
v0.1.0
Published
Listener for DOM and document ready and loaded events
Downloads
25
Keywords
Readme
Ready
DOM ready & document loaded JavaScript listeners
- Lightweight (less than 250b minified and gzipped)
- No dependencies
- Transpile to desired browser target (syntax only)
Built with ❤️ by GRRR.
Installation
$ npm install @grrr/ready
Note: depending on your setup additional configuration might be needed, since this package is published with untranspiled JavaScript.
Usage
Import into your main JavaScript file:
import { onDocumentLoaded, onDomReady } from '@grrr/ready';
onDomReady(() => {
// Execute main functions
});
onDocumentLoaded(() => {
// Execute functions after the document has fully loaded
});
DOM ready
The onDomReady
function:
- Will fire directly when Document.readyState
is not
loading
(sointeractive
orcomplete
). - Listens for both DOMContentLoaded and readystatechange if not yet ready.
Document loaded
The onDocumentLoaded
function:
- Will fire directly when Document.readyState
is
complete
. - Listens for readystatechange if not yet complete.