Created
December 10, 2013 13:02
-
-
Save chrisjhoughton/7890239 to your computer and use it in GitHub Desktop.
Wait for a global variable to exist on the page.
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 waitForGlobal = function(key, callback) { | |
if (window[key]) { | |
callback(); | |
} else { | |
setTimeout(function() { | |
waitForGlobal(key, callback); | |
}, 100); | |
} | |
}; | |
waitForGlobal("jQuery", function() { | |
console.log("found it"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to check nested sub keys, something like this might work: