N
news
A lot of the interactive pages I'm coding at the moment for our
intranet use setInterval to scan for things that need updating,
request data from the server and then render that data back to the
page.
As such, I've often got 3 or 4 intervals running with different time
spacing, adjusted to get the best response without hammering the
server for updates.
Now - should I clear all these intervals in response to an unload
event, or should I let the browser take care of this?
I've always cleared them diligently (prompted by the fact that there
is a function for clearing them), but I realised this morning that
I've never actually read anywhere that this definitely is or is not
necessary.
As a side question, is there any difference between clearTimeout and
clearInterval - in other words do you have to make sure you clear a
reference returned by setTimeout with clearTimeout and so on?
intranet use setInterval to scan for things that need updating,
request data from the server and then render that data back to the
page.
As such, I've often got 3 or 4 intervals running with different time
spacing, adjusted to get the best response without hammering the
server for updates.
Now - should I clear all these intervals in response to an unload
event, or should I let the browser take care of this?
I've always cleared them diligently (prompted by the fact that there
is a function for clearing them), but I realised this morning that
I've never actually read anywhere that this definitely is or is not
necessary.
As a side question, is there any difference between clearTimeout and
clearInterval - in other words do you have to make sure you clear a
reference returned by setTimeout with clearTimeout and so on?