异步加载JS后回调:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
app.dynamicLoadingJs = function (e, d) {
var c = document.createElement("script");
var b = document.getElementsByTagName("head")[0];
c.src = e;
if (typeof d === "function") {
var a;
c.onload = c.onreadystatechange = function () {
if (!a && (!c.readyState || /loaded|complete/.test(c.readyState))) {
c.onload = c.onreadystatechange = null;
a = true;
d();
}
}
}
b.appendChild(c);
};

异步加载CSS后回调:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
app.dynamicLoadingCss = function (e, d) {
var c = document.createElement("link");
var b = document.getElementsByTagName("head")[0];
c.href = e;
c.rel = "stylesheet";
c.type = "text/css";
if (typeof d === "function") {
var a;
c.onload = c.onreadystatechange = function () {
if (!a && (!c.readyState || /loaded|complete/.test(c.readyState))) {
c.onload = c.onreadystatechange = null;
a = true;
d();
}
};
}
b.appendChild(c);
};