Difference between DOMContentLoaded and load events

后端 未结 6 1894
执笔经年
执笔经年 2020-11-22 08:43

What is the difference between DOMContentLoaded and load events?

6条回答
  •  囚心锁ツ
    2020-11-22 09:09

    See the difference yourself:

    DEMO

    From Microsoft IE

    The DOMContentLoaded event fires when parsing of the current page is complete; the load event fires when all files have finished loading from all resources, including ads and images. DOMContentLoaded is a great event to use to hookup UI functionality to complex web pages.

    From Mozilla Developer Network

    The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading (the load event can be used to detect a fully-loaded page).

提交回复
热议问题