Skip to content

Instantly share code, notes, and snippets.

@aisteron
Last active April 2, 2020 08:48
Show Gist options
  • Save aisteron/2646aa7159ce30bf05b5e932023a006a to your computer and use it in GitHub Desktop.
Save aisteron/2646aa7159ce30bf05b5e932023a006a to your computer and use it in GitHub Desktop.
function loadFancy() {
let stack = [
'/vendor/jquery.min.js',
'/vendor/jquery.fancybox.min.js',
'/vendor/loadcss.js'
]
loadIt()
function loadIt() {
if(stack.length > 0) {
let nextLib = stack.shift();
let scriptsArea = document.querySelector('.scripts-area');
let scriptTag = document.createElement('script');
scriptTag.src = nextLib
scriptsArea.appendChild(scriptTag);
scriptTag.onload = () => loadIt()
} else {
let stylesheet = loadCSS( "/vendor/jquery.fancybox.min.css" );
onloadCSS( stylesheet, function() {
console.log( "fancybox styles loaded" );
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment