Skip to content

Instantly share code, notes, and snippets.

@aisteron
Last active May 18, 2020 09:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aisteron/a9e62e81ea56e5b84bcc50c7b5671a06 to your computer and use it in GitHub Desktop.
function $_(element) { return document.querySelector(element) }
let stack = [
'/js/autocomplete/jquery-1.12.4.js',
'/js/autocomplete/jquery-ui.js',
'/js/autocomplete/loadcss.js',
]
loadAutoComplete(stack)
document.addEventListener('ui-styles', () => {
goJq(); // jquery autocomplete
calcDelivery();
})
function loadAutoComplete(stack) {
if(stack.length > 0) {
let nextLib = stack.shift();
let scripts = $_('.scripts-area');
let tag = document.createElement('script');
tag.src = nextLib;
scripts.appendChild(tag)
tag.onload = () => loadAutoComplete(stack)
} else {
let uiStyles = loadCSS('/js/autocomplete/jquery-ui.css');
onloadCSS(uiStyles, () => {
let event = new Event('ui-styles');
document.dispatchEvent(event);
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment