Skip to content

Instantly share code, notes, and snippets.

@milosdjakonovic
Created September 3, 2016 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milosdjakonovic/9814b725b86b0e862e8201124844d791 to your computer and use it in GitHub Desktop.
Save milosdjakonovic/9814b725b86b0e862e8201124844d791 to your computer and use it in GitHub Desktop.
Smallest DOM Ready ever enhanced
/**
* This is patch to famous Dustin Diaz's
* Smallest DomReady Ever
* http://dustindiaz.com/smallest-domready-ever
*
* It is executing argument function inside
* anonimous function specified in setTimeout
*
* That way, we can use Smallest DomReady Ever in
* body/context of self-executing anonimous functions
* as well as any other functions
*
*/
var r = function(f){
/in/.test(document.readyState) ?
setTimeout( function(){ r(f) } ,9)
:f()
}
// Or, minified ( 85 bytes )
var r=function(t){/in/.test(document.readyState)?setTimeout(function(){r(t)},9):t()};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment