Is it really necessary to wait for DOM ready to manipulate the DOM?

前端 未结 4 773
北海茫月
北海茫月 2020-12-11 08:03

Is it really necessary to wait for the \"ready\" (or \"window.onload\") events if your code only manipulates DOM elements that have already been parsed entirely?

The

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 08:35

    Document is loaded in linear fashion so your code works correctly. Sometimes programmers do not use document ready for performance purpose when the javascript is not depends on the DOM below it. Here is some example.

提交回复
热议问题