Skip to content

Instantly share code, notes, and snippets.

@aurooba
Last active April 10, 2023 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aurooba/d9cc53bb0336e4a9d17f5a2a2688de2f to your computer and use it in GitHub Desktop.
Save aurooba/d9cc53bb0336e4a9d17f5a2a2688de2f to your computer and use it in GitHub Desktop.
Vanilla JS alternative to jQuery's $(document).ready
var domReady = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
};
// usage
domReady(() => {
// Do things after DOM has loaded completely
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment