Do I need to explicitly destroy JavaScript objects on window unload?
Posted
by Bilal Aslam
on Stack Overflow
See other posts from Stack Overflow
or by Bilal Aslam
Published on 2010-03-16T17:20:20Z
Indexed on
2010/03/16
17:31 UTC
Read the original article
Hit count: 311
I have a JavaScript widget that is hosted on websites. This widget tracks state in a number of variables in its local namespace. Moreover, it attaches listeners for several events, such as mouse movement.
Should I explicitly destroy both state-tracking variables and detach event listeners on window unload? Or is it ok to rely on the browser to do a good job of cleaning up after the user leaves the page that hosts my widget?
© Stack Overflow or respective owner