Created
May 17, 2012 19:47
-
-
Save mjschranz/2721194 to your computer and use it in GitHub Desktop.
Butter CSS Loader
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
var scriptElement, | |
interval; | |
checkFn = checkFn || function(){ | |
return !!scriptElement; | |
}; | |
function runCheckFn() { | |
interval = setInterval(function(){ | |
if( checkFn() ){ | |
clearInterval( interval ); | |
if( callback ){ | |
callback(); | |
} | |
} | |
}, CSS_POLL_INTERVAL ); | |
} | |
url = fixUrl( url ); | |
if( !checkFn() ){ | |
scriptElement = document.createElement( "link" ); | |
scriptElement.rel = "stylesheet"; | |
scriptElement.onload = runCheckFn; | |
scriptElement.href = url; | |
document.head.appendChild( scriptElement ); | |
} | |
else if( callback ){ | |
callback(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment