Last active
September 26, 2023 20:49
-
-
Save ego-lay-atman-bay/0eecc1e3156ef0bfb23268f47281aa1d to your computer and use it in GitHub Desktop.
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
| // definition | |
| function loadScript(scriptUrl) { | |
| console.log('loading script', scriptUrl); | |
| const script = document.createElement('script'); | |
| script.src = scriptUrl; | |
| document.body.appendChild(script); | |
| return new Promise((res, rej) => { | |
| script.onload = function() { | |
| res({message: 'script loaded'}); | |
| } | |
| script.onerror = function (error) { | |
| rej(error.target); | |
| } | |
| }); | |
| } | |
| function log(message) { | |
| console.log(message); | |
| span = document.createElement('p'); | |
| span.innerHTML = message; | |
| document.body.appendChild(span); | |
| } | |
| // use | |
| loadScript('https://cdn.jsdelivr.net/npm/eruda') | |
| .then((response) => { | |
| log(response.message); | |
| log(eruda); | |
| log('') | |
| for (let a in eruda) { | |
| log(a) | |
| } | |
| eruda.init(); | |
| }) | |
| .catch((error) => { | |
| log(error.message) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment