I have a web application running on a controller (limited processing, memory and network bandwidth). The page is basically a simple HTML file full of LEDs that needs to be updated at intervals. At each interval, Javascript sends an Ajax request to the server and updates all the LEDs based on the response. Now it works great!
The problem is when the user opens one of these pages and starts viewing other materials. For security and economy reasons, we do not want to refresh the page when the client does not see this page. This is the algorithm:

, , (. live on jsFiddle):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function m(msg){
document.getElementById("logplace").innerHTML+=msg+"<br/>";
}
</script>
</head>
<body onblur="m('Blur')" onerror="m('Error')" onfocus="m('Focus')" onload="m('Load')" onresize="m('Resize')" onunload="m('Unload')">
<span id="logplace"></span>
</body>
</html>
, , . Stackoverflow, :
PS. JQuery . , JQuery.