Skip to content

Instantly share code, notes, and snippets.

@dbauszus-glx
Last active August 22, 2022 07:35
Show Gist options
  • Save dbauszus-glx/b827e80d520bfdffcd96269cb714ec92 to your computer and use it in GitHub Desktop.
Save dbauszus-glx/b827e80d520bfdffcd96269cb714ec92 to your computer and use it in GitHub Desktop.
const script = document.createElement("script")
script.type = 'application/javascript'
script.src = 'https://geolytix.github.com/GEOLYTIX/public/blob/v3/public/myPluginScript.js'
let eventTriggered
script.onload = () => {
setTimeout(()=>{
!eventTriggered && console.error('Event not triggered')
document.removeEventListener('myPluginScript', eF, true)
script.remove()
resolve() // resolve promise to load script
}, 400)
}
script.onerror = () => {
document.removeEventListener('myPluginScript', eF, true)
script.remove()
reject() // reject promise to load script
}
document.addEventListener('myPluginScript', eF, true)
document.head.append(script)
function eF(e){
eventTriggered = true
e.detail(_xyz)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment