Here's the code if anybody is interested, it also includes some strategies to avoid adding scripts that are already available globally.
const init = function() {
function loadScript(url) {
return new Promise(function(resolve, reject) {
let script = document.createElement('script');
script.src = url;
script.async = false;
script.onload = function() {
resolve(url);
};
script.onerror = function() {
reject(url);
};
document.body.appendChild(script);
});
};
// we want two versions of gsap to run on the same page
// one will be running at default 60fps, the other will be running at 5fps
window.slowGSAP = {};
window.GreenSockGlobals = window.slowGSAP;
const slowGSAPLoader = loadScript('URL TO GSAP');
slowGSAPLoader.then(function() {
delete window.GreenSockGlobals;
let requiredScripts = [];
let scriptPromises = [];
// reload gsap for normal speeds
requiredScripts.push('URL TO GSAP');
if (typeof window.PIXI === 'undefined') {
requiredScripts.push('URL TO PIXI');
}
if (typeof window.PixiPlugin === 'undefined') {
requiredScripts.push('URL TO PIXI PLUGIN');
}
// prep the promises for promise.all
requiredScripts.forEach(function(url) {
scriptPromises.push(loadScript(url));
});
// wait for everything to load before starting our animation script
Promise.all(scriptPromises).then(YOURFUNCTIONHERE);
});
}();
(sorry for the lack of arrow functions)