Created
April 2, 2020 12:55
-
-
Save SteGriff/4c6ce46e20f3cf663e5caadd5f7e458a to your computer and use it in GitHub Desktop.
OnReady function for HTML DOM instead of JQuery
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
| // Better than JQuery ready function... or at least doesn't require JQuery :) | |
| app = function() { | |
| this.onReady = function (callback) { | |
| if (document.readyState != 'loading') callback() | |
| else document.addEventListener('DOMContentLoaded', callback) | |
| } | |
| }; | |
| const myApp = new app(); | |
| myApp.onReady(function(){ // Do something }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment