Last active
October 22, 2020 09:58
-
-
Save m3g4p0p/47ee11e7b5102148e292ccc6440fe83d to your computer and use it in GitHub Desktop.
Dynamically load JavaScript
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
// Using vanilla JS | |
const script = document.createElement('script') | |
script.src = 'my-script.js' | |
document.body.appendChild(script) | |
// Using jQuery | |
const $script = $('<script />').prop('src', 'my-script.js') | |
$(document.body).append($script) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment