(function(a) {
function B(a, b) {
if (a.nodeName === "IMG") {
D(a, b);
return
}
a.nodeName === "SCRIPT" ? E(a, b) : F(a, b)
}
function C(a) {
o ? a.removeNode() : a && a.parentNode && a.parentNode.removeChild(a),
a = undefined
}
function D(a, b) {
a.onload = a.onerror = function() {
a.onload = a.onerror = null,
C(a),
b()
}
}
function E(a, b) {
a.onload = a.onerror = a.onreadystatechange = function() {
t.test(a.readyState) && (a.onload = a.onerror = a.onreadystatechange = null, C(a), b())
}
}
function F(a, b) {
e || f ? setTimeout(function() {
G(a, b)
},
1) : a.onload = a.onerror = function() {
a.onload = a.onerror = null,
a = undefined,
b()
}
}
function G(a, b) {
var c;
if (e) a.sheet && (c = !0);
else if (a.sheet) try {
a.sheet.cssRules && (c = !0)
} catch(d) {
d.name === "NS_ERROR_DOM_SECURITY_ERR" && (c = !0)
}
setTimeout(function() {
c ? b() : G(a, b)
},
1)
}
function H() {}
function I() {
var a, d, e, f, g;
if (document.currentScript) return document.currentScript;
if (document.attachEvent) {
if (b) return b;
if (c && c.readyState === "interactive") return c;
a = n.getElementsByTagName("script");
for (d = 0; d < a.length; d++) {
e = a[d];
if (e.readyState === "interactive") return c = e,
e
}
} else {
try {
makeReferenceError
} catch(g) {
f = g.stack
}
if (!f) return undefined;
g = f.indexOf(" at ") !== -1 ? " at ": "@";
while (f.indexOf(g) !== -1) f = f.substring(f.indexOf(g) + g.length);
f = f.replace(/:\d+:\d+$/ig, ""),
a = document.getElementsByTagName("script");
for (d = a.length - 1; d > -1; d--) if (a[d].src === f) return a[d]
}
}
function J() {
var a = I();
return a ? a.hasAttribute ? a.src: a.getAttribute("src", 4) : ""
}
function K(b) {
var c = !1,
d = !0,
e = a.document,
f = e.documentElement,
g = e.addEventListener ? "addEventListener": "attachEvent",
h = e.addEventListener ? "removeEventListener": "detachEvent",
i = e.addEventListener ? "": "on",
j = function(d) {
if (d.type == "readystatechange" && e.readyState != "complete") return; (d.type == "load" ? a: e)[h](i + d.type, j, !1),
!c && (c = !0) && b.call(a, d.type || d)
},
k = function() {
try {
f.doScroll("left")
} catch(a) {
setTimeout(k, 50);
return
}
j("poll")
};
if (e.readyState == "complete") b.call(a, "lazy");
else {
if (e.createEventObject && f.doScroll) {
try {
d = !a.frameElement
} catch(l) {}
d && k()
}
e[g](i + "DOMContentLoaded", j, !1),
e[g](i + "readystatechange", j, !1),
a[g](i + "load", j, !1)
}
}
function L() {
var a, b = 0;
if (h.length) for (; a = h[b++];) a()
}
var b, c, d, e, f, g, h, i, j, k, l, m = document,
n = m.head || m.getElementsByTagName("head")[0] || m.documentElement,
o = !1,
p = n.getElementsByTagName("base")[0],
q = /\.jpg|jpeg|png|gif|bmp(?:\?|$)/i,
r = /\.css(?:\?|$)/i,
s = /\.js(?:\?|$)/i,
t = /loaded|complete|undefined/,
u = m.createElement("script").async === !0 || "MozAppearance" in m.documentElement.style || window.opera,
v = Array.prototype,
w = Object.prototype.toString,
x = function(a) {
return w.call(a) === "[object Function]"
},
y = function(a) {
return w.call(a) === "[object String]"
},
z = function(a) {
return w.call(a) === "[object Array]"
},
A = function(a, c, d, e, f) {
var g = r.test(a),
h = q.test(a),
i = h ? new Image: document.createElement(g ? "link": "script");
if (s.test(a) && d) {
var j = x(d) ? d(a) : d;
j && (i.charset = j)
}
B(i, c || H);
if (h) {
i.src = a;
return
}
g ? (i.rel = "stylesheet", i.href = a) : (i.async = e ? "async": !1, i.type = "text/" + (f || "javascript"), i.src = a),
b = i,
p ? n.insertBefore(i, p) : n.appendChild(i),
b = null
};
d = navigator.userAgent,
e = Number(d.replace(/.*AppleWebKit\/(\d+)\..*/, "$1")) < 536,
f = d.indexOf("Firefox") > 0 && !("onload" in document.createElement("link")),
g = [],
h = [],
i = {},
j = {
charset: "gbk",
type: "order"
},
k = function(a, b) {
var c = arguments,
d = g.length,
e = d - 1,
f = g[e],
h = j.charset,
k = I(),
l,
m = function(a) {
if (d == 0) {
a();
return
}
if (J()) {
a();
return
}
if (f) {
f.loaded ? a() : f.callChain.push(a);
return
}
a()
};
if (!x(a) && !y(a)) return;
if (x(a)) {
b = a,
m(b);
return
}
b || (b = H);
if (c.length === 1) return i[a] && i[a].exports;
i[a] = {
init: function() {
var c = i[a].exports;
return b(c),
c
},
exports: {}
},
l = i[a].init,
m(l)
},
l = function(b) {
var c = b.callChain,
d = c.length;
for (var e = 0; e < d; e++) c[e].call(a);
b.called = !0
},
k.executeOrder = function(a, b) {
var c, d = j.charset,
e = function() {
var a = g[c],
b = g.length,
f = g[c - 1],
h = g[c + 1];
a.loaded = !0,
l(a);
if (h && h.preloaded) {
c++,
A(h.url, e, d);
return
}
},
f = function() {
A(a,
function() {
var b = g[c],
f = g.length,
h = g[c - 1];
b.preloaded = !0,
(c == 0 || h && h.called) && A(a, e, d)
},
j.charset, null, "cache")
};
g.push({
url: a,
callChain: [b],
perloaded: !1,
loaded: !1,
called: !1
}),
c = g.length - 1,
u ? A(a,
function() {
l(g[c])
},
j.charset) : f()
},
k.executeNow = function(a, b) {
A(a, b, j.charset, !0)
},
k.load = function(b, c, d) {
var e;
return y(c) && (d = c, c = H),
arguments.length == 1 && (c = H),
d = s.test(b) ? d || j.type: "now",
e = "execute" + d.charAt(0).toUpperCase() + d.substring(1),
k[e] && k[e].call(a, b, c, j.charset)
},
k.ready = function(a, b) {
x(a) && arguments.length == 1 && (b = a),
h.push(function() {
k(a, b)
})
},
k.clean = function() {
g = [],
i = [],
h = []
},
K(function() {
L()
}),
k.modules = i,
k.config = j,
a.pump = k
})(window);
javascript - www.1688.com首頁的這段JS程式碼是幹嘛用的? -PHP中文網問答-javascript - www.1688.com首頁的這段JS程式碼是乾嘛用的? -PHP中文網問答
圍觀一下哦,學習一下。
看到第100行,以及各种script,各种图片脚本和CSS的后缀,以及各种异步事件,有理由相信这段代码是用来做lazyload的,当然本人仅仅是猜测,也可能不仅仅是干这个的或者是基本上不干这个的。