Skip to content

Instantly share code, notes, and snippets.

@sonnyp
Last active October 10, 2015 04:47
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 sonnyp/3635320 to your computer and use it in GitHub Desktop.
Save sonnyp/3635320 to your computer and use it in GitHub Desktop.
Execute some DOM related operation when document is ready
var whenDocumentIsReady = function(callback) {
if (document.readyState !== 'loading')
callback.call(document);
else
document.addEventListener('DOMContentLoaded', callback);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment