Created
January 4, 2020 18:51
-
-
Save davidcalhoun/cabe908b3e5c1ceddb16a08e7fcc69bb to your computer and use it in GitHub Desktop.
simple script loader.js
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 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