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?