Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple script loader.js
function initSyntaxHighlighting() {
// code
}
function loadScripts() {
const scripts = [
{
src: 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js',
callback: initSyntaxHighlighting
}
];
scripts.forEach(function(script) {
const elt = document.createElement('script');
elt.setAttribute('async', '');
elt.setAttribute('defer', '');
elt.setAttribute('src', script.src);
elt.addEventListener('load', script.callback, true);
document.head.appendChild(elt);
});
}
loadScripts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.