(win, url, opt_cb, opt_errorCb)
| 83 | * @param {function()=} opt_errorCb |
| 84 | */ |
| 85 | export function loadScript(win, url, opt_cb, opt_errorCb) { |
| 86 | /** @const {!Element} */ |
| 87 | const s = win.document.createElement('script'); |
| 88 | s.src = url; |
| 89 | if (opt_cb) { |
| 90 | s.onload = opt_cb; |
| 91 | } |
| 92 | if (opt_errorCb) { |
| 93 | s.onerror = opt_errorCb; |
| 94 | } |
| 95 | win.document.body.appendChild(s); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Call function in micro task or timeout as a fallback. |
no outgoing calls
no test coverage detected