Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 12, 2022. It is now read-only.
/ whenReady Public archive

Cross-browser DOMContentLoaded event

Notifications You must be signed in to change notification settings

kukawski/whenReady

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

This small function tries to emulate DOMContentLoaded event in a cross-browser manner.

To use this function, just include the file in your document

<script type="text/javascript" src="whenReady.js"></script>

and call the function as many times you need

<script type="text/javascript">
whenReady(function () {
 console.log("1");
});
whenReady(function () {
 console.log("2");
});
setTimeout(function () {
 whenReady(function () {
 console.log("3");
 });
}, 15000);
</script>

The function assures all the callbacks are called when the document is ready, in the order they were registered. If you call whenReady after the document has loaded, the callback is called immediately. Just make sure, none of the callbacks throws errors, because the function will stop calling remaining callbacks.

About

Cross-browser DOMContentLoaded event

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /