<script>var JSdep = [
["//ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.4.min.js", "window.jQuery", "/bundle/jquery"],
["//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js", "self.framework === 'bootstrap'", "/bundle/bootstrap"],
["//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js", "window.jQuery && window.jQuery.ui && window.jQuery.ui.version === '1.12.1'", "/bundle/jqueryui"],
["//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js", "window.jQuery && window.jQuery.fn.selectpicker", "/bundle/bootstrap-select"],
]
</script>
<script type="text/javascript">
var downloadJSAtOnload = function (e) {
var src = e.srcElement.src.toString();
//console.log("[jquery] loaded", src);
for (var i = 0; i < JSdep.length; i++) {
if (src.indexOf(JSdep[i][0]) !== -1) {
if ((!JSdep[i][1]) || (eval(JSdep[i][1]))) {
console.log("[jquery] loaded ok", src);
break;
} else {
console.log("[jquery] fail", src);
return;
}
}
}
if (i === JSdep.length) {
console.log("[jquery] fallback loaded ok", src);
}
if (jqloaded) {
return;
}
jqloaded = true;
for (var i = 1; i < JSdep.length; i++) {
//console.log("[jquery] loading", JSdep[i][0], JSdep[i][1], JSdep[i][2]);
var raf2 = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf2) { window.setTimeout(dljquery([JSdep[i][0], JSdep[i][1], JSdep[i][2]]), 0); }
else window.addEventListener('load', dljquery([JSdep[i][0], JSdep[i][1], JSdep[i][2]]));
}
}
var downloadJSAtOnerror = function (e) {
var src = e.srcElement.src.toString();
console.log("[jquery] error", src);
for (var i = 0; i < JSdep.length; i++) {
if (src.indexOf(JSdep[i][0]) !== -1) {
console.log("[jquery] failed try fallback", src);
dljquery([JSdep[i][2], JSdep[i][1]]);
return;
}
}
console.log("[jquery] failed on fallback", src);
return;
}
// Add a script element as a child of the body
var dljquery = function (src) {
//console.log("[jquery] start", src);
var element = document.createElement("script");
element.src = src[0];
element.async = "async";
try {
document.body.appendChild(element);
} catch (err) {
console.log("[jquery] err", err);
}
if (element.addEventListener) {
element.addEventListener("load", downloadJSAtOnload, false);
element.addEventListener("error", downloadJSAtOnerror, false);
} else if (element.attachEvent) {
element.attachEvent("onload", downloadJSAtOnload);
element.attachEvent("onerror", downloadJSAtOnerror);
} else {
element.onload = downloadJSAtOnload;
element.onerror = downloadJSAtOnerror;
}
}
// var fb = "/bundle/jquery";
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(function () { window.setTimeout(dljquery([JSdep[0][0], JSdep[0][1], JSdep[0][2]]), 0); });
else window.addEventListener('load', dljquery([JSdep[0][0], JSdep[0][1], JSdep[0][2]]));
var jqloaded = false;
function doOnload() {
console.log("[jquery] onload");
}
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", doOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", doOnload);
else window.onload = doOnload;
</script>
发现它我在 jquery 之前有时会遇到引导加载问题 np 希望它可以帮助其他人一个事件告诉我下载何时结束,有时在 jquery 之前加载引导程序,反之亦然,因为引导程序依赖于 jquery 我必须加载 jquery 然后开始下载引导程序现在我将添加回退
修复
现在它检查 jq 是否已加载
然后才加载其他
好的,现在它的复制粘贴