这个网站是一个JavaScript函数,用于测量和记录网页加载时间。它通过在浏览器中添加一个计时器来实现这一功能。具体来说,当页面加载时,计时器开始计时;当页面完全载入时,计时器停止并记录当前时间(单位是毫秒)。
这个网站的代码如下:
(function () {
var noop = function noop() {};
if ("performance" in window === false) {
window.performance = {};
}
window.performance.mark = performance.mark || noop;
window.performance.measure = performance.measure || noop;
if ("now" in window.performance === false) {
var nowOffset = Date.now();
if (performance.timing && performance.timing.navigationStart) {
nowOffset = performance.timing.navigationStart;
}
window.performance.now = function now() {
return Date.now() - nowOffset;
};
}
})();
这段代码中的 (fun
部分似乎是一个误打,可能是 “function” 的拼写错误。