Skip to content

Instantly share code, notes, and snippets.

@ZenwalkerD
Last active September 28, 2020 06:34
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 ZenwalkerD/ed2982b84277781462344e3f4f9e8148 to your computer and use it in GitHub Desktop.
Save ZenwalkerD/ed2982b84277781462344e3f4f9e8148 to your computer and use it in GitHub Desktop.
loadDynamicScript(): Promise<any> {
let that: this = this;
return new Promise((resolve, reject) => {
if (isNullOrUndefined(window.document.getElementById(this.id))) {
const scriptElement = window.document.createElement('script');
scriptElement.id = this.id;
scriptElement.src = 'https://<Remote storage URL>/external-widgets/plotly.js/1.48.3/plotly.min.js';
scriptElement.onload = () => {
resolve();
};
scriptElement.oncancel = () => {
window.document.getElementById(this.id).remove();
reject();
};
scriptElement.onerror = () => {
window.document.getElementById(this.id).remove();
reject();
};
window.document.body.appendChild(scriptElement);
}
else resolve();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment