Skip to content

Instantly share code, notes, and snippets.

@ruan4261
Last active April 17, 2021 08:03
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 ruan4261/7ec3005c3cb8e086a50c6f97bbb83bf0 to your computer and use it in GitHub Desktop.
Save ruan4261/7ec3005c3cb8e086a50c6f97bbb83bf0 to your computer and use it in GitHub Desktop.
window.dynamic_import_javascript = function(url, text, type, frameWindow){
frameWindow = frameWindow || window
var doc = frameWindow.document
var container = frameWindow.document.head || frameWindow.document.body
var newEle = doc.createElement('script')
if (url)
newEle.src = url
if (text)
newEle.appendChild(document.createTextNode(text))
newEle.type = type || 'text/javascript'
container.append(newEle)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment