Last active
April 10, 2023 12:18
-
-
Save aurooba/d9cc53bb0336e4a9d17f5a2a2688de2f to your computer and use it in GitHub Desktop.
Vanilla JS alternative to jQuery's $(document).ready
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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