Using DOMContentReady considered anti-pattern by Google

后端 未结 7 2269
广开言路
广开言路 2020-12-08 05:20

A Google Closure library team member asserts that waiting for DOMContentReady event is a bad practice.

The short story is that we don\'t want to wai

7条回答
  •  被撕碎了的回忆
    2020-12-08 05:31

    I think this advise is not really helpful. DOMContentReady may only be bad practice because it currently is over-used (maybe because of jquery's easy-to-use ready event). Many people use it as the "startup" event for any javascript action. Though even jQuery's ready() event was only meant to be used as the startup point for DOM manipulations.

    Inferential, DOM manipulations on page load lead to bad user experience!! Because they are not necessary, the server side could just have completely generated the initial page.

    So, maybe the closure team members just try to steer in the opposite direction, and prevent people from doing DOM manipulations on page load at all?

提交回复
热议问题