Last active
April 2, 2020 08:48
-
-
Save aisteron/2646aa7159ce30bf05b5e932023a006a to your computer and use it in GitHub Desktop.
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
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