Skip to content

Instantly share code, notes, and snippets.

@jwalsh
Created April 29, 2013 19:24
Show Gist options
  • Save jwalsh/5484027 to your computer and use it in GitHub Desktop.
Save jwalsh/5484027 to your computer and use it in GitHub Desktop.
// Assume bkContinue is functionality that has a synchronous
// dependency on the tag
// Add a script request with an onload
window.bk_loaded = false;
function bkLoaded() {
// The interval / timeout clearing could be moved here
window.bk_loaded = true;
}
// This is the base implementation of the JS tag
document.write("<scr"+"ipt onload=\"bkLoaded\" src=\"http://tags.bluekai.com/site/14445?ret=js\"></script>");
// Monitor for the completion of bk_loaded
var bk_monitor = window.setInterval(function() {
if (bk_loaded) {
// Stop monitoring
clearInterval(bk_monitor);
// Remove the timeout monitoring if the load doesn't finish
window.clearTimeout(bk_continue);
bkContinue();
}
}, 50)
// Stop monitoring and continue
var bk_continue = window.setTimeout(function() {
// Set up default values or error notes
var bk_results = {
"campaigns": [
]
};
bkContinue();
}, 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment