JavaScript:停止事件传播对性能有好处吗? [英] JavaScript: Is there any performance benefit to stopping event propagation?

查看:78
本文介绍了JavaScript:停止事件传播对性能有好处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否将其视为停止JavaScript事件传播的好习惯"-它以任何方式对性能都有好处吗?

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.

推荐答案

仅在程序逻辑必要时,例如防止表单提交或另一个DOM元素的动作被触发.除非您有一个非常复杂的DOM树,否则不会对性能造成任何严重的影响.

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.

这篇关于JavaScript:停止事件传播对性能有好处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆