MCMastery
MCMastery

Reputation: 3249

Does a timer created with `setInterval` have to be cleaned up before the window is closed?

I am making a game using Javascript, and to update the game I am using setInterval(). Should I use clearInterval() somehow on the window exit, or does it automatically stop?

Upvotes: 6

Views: 503

Answers (1)

Felk
Felk

Reputation: 8224

The browser is (or better: should be) clever enough to fully clean up a closed website. That includes aborting it's running connections and terminating scripts. Data that stays on your PC after you close the tab usually only includes stuff like browser history entries, cookies, local storage and cached data (e.g. scripts, stylesheets, images).

Upvotes: 7

Related Questions