Created
September 3, 2016 10:56
-
-
Save milosdjakonovic/9814b725b86b0e862e8201124844d791 to your computer and use it in GitHub Desktop.
Smallest DOM Ready ever enhanced
This file contains 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
/** | |
* 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