14 lines
351 B
JavaScript
14 lines
351 B
JavaScript
/* jshint -W060 */
|
|||
|
|
import absoluteUrl from './absoluteUrl';
|
||
|
|
|
||
|
|
export default function writeScript(fileName, callback) {
|
||
|
|
const script = document.createElement('script');
|
||
|
|
script.src = absoluteUrl(fileName);
|
||
|
|
script.onload = () => {
|
||
|
|
if (typeof callback === 'function') {
|
||
|
|
callback(script);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
document.body.appendChild(script);
|
||
|
|
}
|