Created
December 12, 2012 19:13
-
-
Save ptone/4270659 to your computer and use it in GitHub Desktop.
load popcorn dynamically
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
// load popcorn dynamically | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = '/static/js/popcorn.js'; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
function popcornReady() { | |
// this is called when script loaded, but before Popcorn global ready | |
console.log("popcorn ready callback"); | |
// console.log(Popcorn); | |
} | |
script.onreadystatechange= function () { | |
if (this.readyState == 'complete') popcornReady(); | |
} | |
// this also does not work: | |
script.onload= popcornReady(); | |
window.onload = function() { | |
//Popcorn is only now available | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment