Skip to content

Instantly share code, notes, and snippets.

@bantic
Created February 10, 2019 20:36
Show Gist options
  • Save bantic/30a269e5d222c4ad2f6eba5081c79455 to your computer and use it in GitHub Desktop.
Save bantic/30a269e5d222c4ad2f6eba5081c79455 to your computer and use it in GitHub Desktop.
function setup() {
console.log('hello from p5 setup');
}
window.setup = setup;
function draw() {
window.ellipse(50, 50, 80, 80);
}
window.draw = draw;
function injectP5(callback) {
let script = document.createElement('script');
script.setAttribute(
'src',
'//cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js'
);
script.onload = () => callback();
script.onerror = e => alert('The script failed to load: ' + e);
document.head.appendChild(script);
}
injectP5(function() {
console.log('p5 was injected v2');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment