I have the following scenario.
My twitter feed should refresh every 5 seconds (by using the load() function). Although I have been monitoring my bandwidth and it really sucks up a lot.
My idea was to stop refreshing as soon as the user goes inactive (say, 5 or 10 seconds no interaction on the page). I tried a few plugins but without success.
The refreshing goes as follows:
setInterval(function() { $("#feed").load("feed.php"); }, 5000);
It should stop refresh, but the plugins I tried just kept refreshing (running the interval).
Is there any way to achieve this? I tried the following plugins:
– http://www.bedroomlan.org/coding/detecting-‘idle’-and-‘away’-timeouts-javascript
– http://www.erichynds.com/jquery/a-new-and-improved-jquery-idle-timeout-plugin/
Thanks in advance.
The easiest way is to use the
idleTimerjQuery plugin.One of it’s capabilities is to get the amount of time since the user was last active. It allows you to write the following code.