Skip to content

Instantly share code, notes, and snippets.

@aisteron
Last active Apr 2, 2020
Embed
What would you like to do?
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