Created
December 11, 2019 10:42
-
-
Save svirmi/41be9d08df7634a60ce547de6088c553 to your computer and use it in GitHub Desktop.
Load script with callback
This file contains hidden or 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
| function loadScript(id, url, callback) { | |
| const script = document.createElement('script'); | |
| script.type = 'text/javascript'; | |
| script.id = id; | |
| script.src = url; | |
| // Several events for cross browser compatibility. | |
| script.onreadystatechange = callback; | |
| script.onload = callback; | |
| // Appending the element will trigger the script load | |
| document.head.appendChild(script); | |
| } | |
| // source https://develop.zendesk.com/hc/en-us/community/posts/360001652887-Web-Widget-API-Hide-Launcher-Button |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment