UNPKG

simple2k13

Version:
18 lines 615 B
const importScript = (url, name, attributes = {}) => { if (name) { name = `script${name}`; if (document.querySelector(`#${name}`)) return; } const script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', url); name && script.setAttribute('id', name); for (const [key, value] of Object.entries(attributes)) { //@ts-ignore script.setAttribute(key, value); } document.querySelector('head')?.appendChild(script); }; export default importScript; //# sourceMappingURL=index.js.map