//方法1----------------------------------------
document.write("<script src='js/external.js'><\/script>");

//方法2----------------------------------------
/**
动态加载JS
@param {string} url 脚本地址
@param {function} callback 回调函数
*/
function loadJS(url, callback) {
let script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
if (typeof (callback) === "function") {
script.onload =
script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
callback();
script.onload = script.onreadystatechange = null;
}
};
}
document.querySelector("html").appendChild(script);
}