admin管理员组

文章数量:1310519

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.

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.

Share Improve this question edited Sep 19, 2019 at 17:34 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Apr 21, 2016 at 3:44 Francisco PresenciaFrancisco Presencia 8,8587 gold badges49 silver badges94 bronze badges 1
  • 1 Hey @BrianTompsett-汤莱恩, as you can see there is a 5 year gap and that makes a world of a difference. In the linked question, the answer is "yes", while when I asked this question in 2016 the answer was "no". So it's definitely not a duplicate. – Francisco Presencia Commented Sep 20, 2019 at 16:56
Add a ment  | 

1 Answer 1

Reset to default 9

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.

本文标签: javascriptDo I need to remove event listeners in 2016Stack Overflow