Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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