Improve script performance
This commit is contained in:
parent
3f7aaa8f0d
commit
39ef4c9645
@ -4,6 +4,9 @@ window.onload = function () {
|
|||||||
Math.random().toString(36).substring(2, 15);
|
Math.random().toString(36).substring(2, 15);
|
||||||
function sendUpdate() {
|
function sendUpdate() {
|
||||||
try {
|
try {
|
||||||
|
if (document.hidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(
|
xhr.open(
|
||||||
"POST",
|
"POST",
|
||||||
@ -21,8 +24,8 @@ window.onload = function () {
|
|||||||
window.performance.timing.navigationStart,
|
window.performance.timing.navigationStart,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
setInterval(sendUpdate, Number("{{heartbeat_frequency}}"));
|
setInterval(sendUpdate, parseInt("{{heartbeat_frequency}}"));
|
||||||
sendUpdate();
|
sendUpdate();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user