Skip to content

Instantly share code, notes, and snippets.

@tommyh
Last active December 22, 2015 01:30
Show Gist options
  • Save tommyh/db777fddbdc5040b8dc3 to your computer and use it in GitHub Desktop.
Save tommyh/db777fddbdc5040b8dc3 to your computer and use it in GitHub Desktop.
onGlobalDefined
var onGlobalDefined = function(func, varName){
if(typeof window[varName] !== "undefined"){
console.log("running");
func();
} else {
console.log("waiting");
setTimeout(function(){
onGlobalDefined(func, varName);
}, 10);
}
}
onGlobalDefined(function(){
alert("window.BKTAG" is ready");
}, "BKTAG");
@tommyh
Copy link
Author

tommyh commented Dec 22, 2015

onPropertyDefined(function(){}, function(){ return window.BKTAG });
onPropertyDefined(function(){}, "BKTAG");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment