Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to remove event listeners in 2016?

This question was asked and answered in 2011. However, the web scene has taken a considerable change and now IE6 and IE7 are out, IE8-10 are barely out (under 1% each) and only IE11 is still there.

So, in 2016, do you need to manually remove event listeners to avoid memory leaks? Consider only IE11 for the answer please. I am asking because I created a small library as an alternative to jQuery and would love to know if I have to remove them manually first. Of course the question is when using vanilla javascript, not jQuery.

like image 459
Francisco Presencia Avatar asked Apr 21 '16 03:04

Francisco Presencia


1 Answers

No

See these answers:

  • Do I need to remove event listeners?
  • If a DOM Element is removed, are its listeners also removed from memory?

Also:

  • This article claims the DOM + JS reference cycle memory leak was fixed in IE8.

Edit: The article linked above is gone. Here is a wayback machine snapshot.

like image 79
JosiahDaniels Avatar answered Oct 22 '22 11:10

JosiahDaniels