Why events aren't detached on unload?

Skip to first unread message

Daniel Steigerwald

Oct 28, 2010, 8:43:53 AM10/28/10
to Closure Library Discuss
Was DOM evens deregistration considered as antipattern? Or does Google
Closure use another approach? Or is detaching deferred to the user?
Or ..?
Thanx for answer.

Shawn Brenneman

Oct 29, 2010, 1:22:08 AM10/29/10
to closure-lib...@googlegroups.com
The library doesn't automatically unregister the listeners on page
unload. It's easy to add your own listener for the window unload event
and have it call goog.events.removeAll(). The events system is
believed to be reasonably resistant to memory leaks, but explicitly
removing all event handlers doesn't hurt.


Daniel Steigerwald

Oct 29, 2010, 4:49:42 AM10/29/10
to Closure Library Discuss
Thank you for your answer. So, closure does not leak, even when it
does not automatically remove events at unload.
So every other js library does pointless unload removing? Funny ;)
The potential problem with unload registration can be, than u can use
reliably only once. Two unloads, first would remove second :)

Reply all
Reply to author
0 new messages