Why events aren't detached on unload?

56 views
Skip to first unread message

Daniel Steigerwald

unread,
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

unread,
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.

Shawn

Daniel Steigerwald

unread,
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 :)

d.
Reply all
Reply to author
Forward
0 new messages