Skip to content

Instantly share code, notes, and snippets.

@m3g4p0p
Last active October 22, 2020 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m3g4p0p/47ee11e7b5102148e292ccc6440fe83d to your computer and use it in GitHub Desktop.
Save m3g4p0p/47ee11e7b5102148e292ccc6440fe83d to your computer and use it in GitHub Desktop.
Dynamically load JavaScript
// 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