Last active
November 18, 2023 02:17
-
-
Save ZacharyCouchman/6da12b81c8b0f5382bbb39e61809802e to your computer and use it in GitHub Desktop.
Dynamically load a script into the dom
This file contains 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 loadScript() { | |
// create a script element | |
let ourScript = document.createElement('script'); | |
// add the src, where we are loading the script from | |
ourScript.src = "https://cdn.jsdelivr.net/..."; | |
// append the script to the doucment head (load the script into the DOM) | |
document.head.appendChild(ourScript); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment