Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32568

Re: removeEventListener why

Path csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: removeEventListener why
Date Thu, 09 Feb 2017 02:02:50 +0100
Organization PointedEars Software (PES)
Lines 46
Message-ID <19314122.EfDdHjke4D@PointedEars.de> (permalink)
References <hbCdnUYE2rVRhQTFnZ2dnUU7-dvNnZ2d@westnet.com.au> <o7bjl9$rir$1@dont-email.me> <XnsA71576F20B91eejj99@194.109.6.166> <17lq30tu5zsgb$.xcbdekfxmxh$.dlg@40tude.net>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace solani.org 1486602170 2311 eJwFwYEBwCAIA7CXQNoyzxmI/59gwpCrE6LAy+tliTirsY+ya08gylBqq0v2/DEMfSK81zwYfBD4 (9 Feb 2017 01:02:50 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 9 Feb 2017 01:02:50 +0000 (UTC)
User-Agent KNode/4.14.2
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-User-ID eJwNxdEVADEEBMCWCHafcpDov4S7+ZkwKIaOgMfGkuMGVmZFOe4+E1bwRffTLUrlZNvylExfvVidFf93kfMBY04WGQ==
Cancel-Lock sha1:2m8c/33FJOA5fr9RrVsNmxLbSZU=
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
X-NNTP-Posting-Host eJwFwQkBACAIBLBKCMcXB0H6R3BTsWPtMDXo6roDHHc260z2mxuEiHwEFjSbMkmh6w5Jjn8WuxDT
Xref csiph.com comp.lang.javascript:32568

Show key headers only | View raw


JJ wrote:

> On Tue, 07 Feb 2017 11:41:34 +0100, Evertjan. wrote:
>> No, you should not.
>> 
>> Any 'page' has so many listenters by default that you trust are destroyed
>> when you leave the page, you could as well suspect a modern browser not
>> keeping good care for that. btw, should you reset all variables before
>> you exit a page too?
>> 
>> Memory-leakage is a task for the [individual browser]-maker to worry
>> about, not for the page programmer.
> 
> This won't work when developing some kind of HTML demo which can be
> stressful such as HTML based particle demo.
> 
> e.g. the script creates many elements and listen to them. Before
> presenting the next set of demo, if it simply remove the elements without
> removing the listeners, the garbage will fill up eventually. When the
> browser finally collect the garbage, it may interfere the progress of the
> current demo.

You are grasping at straws here.

1. The HTML demo, if professionally done, would not attach event listeners 
   to each element, but delegate them to an upper level, probably the 
   document, based on the properties of the element.

2. The HTML demo would not add elements and event listeners on the fly,
   because modifying the document tree extensively after the document
   has been loaded incurs a performance penalty and a risk of failure
   that a presenter cannot afford.

3. The HTML demo would be for a sufficiently recent user agent in which
   this bug has been fixed.

4. There is no good reason to assume that an event listener for a hidden
   element would be interfering with one for a displayed one.

Your example is unrealistic, to say the least.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

removeEventListener why Andrew Poulos <ap_prog@hotmail.com> - 2017-02-07 11:46 +1100
  Re: removeEventListener why "Julio P. Di Egidio" <julio@diegidio.name> - 2017-02-07 05:51 +0100
    Re: removeEventListener why "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-07 11:41 +0100
      Re: removeEventListener why Julio Di Egidio <julio@diegidio.name> - 2017-02-07 03:00 -0800
        Re: removeEventListener why "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-07 12:44 +0100
      Re: removeEventListener why JJ <jj4public@vfemail.net> - 2017-02-07 22:50 +0700
        Re: removeEventListener why "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-07 18:17 +0100
          Re: removeEventListener why JJ <jj4public@vfemail.net> - 2017-02-08 23:11 +0700
            Re: removeEventListener why "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-08 19:39 +0100
        Re: removeEventListener why Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-09 02:02 +0100
          Re: removeEventListener why Julio Di Egidio <julio@diegidio.name> - 2017-02-08 20:33 -0800
            Re: removeEventListener why "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-09 11:51 +0100
            Re: removeEventListener why Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-09 12:01 +0100
          Re: removeEventListener why JJ <jj4public@vfemail.net> - 2017-02-09 18:36 +0700
            Re: removeEventListener why Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-09 13:09 +0100
  Re: removeEventListener why "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-02-07 06:32 -0800
    Re: removeEventListener why Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 17:31 +0100
      Re: removeEventListener why Julio Di Egidio <julio@diegidio.name> - 2017-02-07 11:59 -0800
        Re: removeEventListener why Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 21:55 +0100
          Re: removeEventListener why Julio Di Egidio <julio@diegidio.name> - 2017-02-07 13:23 -0800
            Re: removeEventListener why "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-02-08 06:03 -0800
      Re: removeEventListener why "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-02-08 05:54 -0800

csiph-web