Search code examples
javascriptevent-propagation

JavaScript: Is there any performance benefit to stopping event propagation?


Is it considered 'good practice' to stop JavaScript event propagation - does it benefit performance in any way?

I'm wondering if there is benefit outside of layout purposes where you stop propagation so you don't trigger multiple events accidentially.


Solution

  • Only when it is necessary to the program logic, such as to prevent form submission or another DOM element's action being triggered. Unless you have a seriously complex DOM tree, there will not be any serious performance hit.