Skip to content

Instantly share code, notes, and snippets.

@SteGriff
Created April 2, 2020 12:55
Show Gist options
  • Select an option

  • Save SteGriff/4c6ce46e20f3cf663e5caadd5f7e458a to your computer and use it in GitHub Desktop.

Select an option

Save SteGriff/4c6ce46e20f3cf663e5caadd5f7e458a to your computer and use it in GitHub Desktop.
OnReady function for HTML DOM instead of JQuery
// 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