UNPKG

cesium

Version:

CesiumJS is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin.

27 lines (22 loc) 551 B
import defer from "./defer.js"; /** * @private */ function loadAndExecuteScript(url) { const deferred = defer(); const script = document.createElement("script"); script.async = true; script.src = url; const head = document.getElementsByTagName("head")[0]; script.onload = function () { script.onload = undefined; head.removeChild(script); deferred.resolve(); }; script.onerror = function (e) { deferred.reject(e); }; head.appendChild(script); return deferred.promise; } export default loadAndExecuteScript;