gpt4 book ai didi

javascript - 延迟脚本与预加载链接有何不同?

转载 作者:行者123 更新时间:2023-12-05 00:27:53 25 4
gpt4 key购买 nike

Preload: fetch a CSS stylesheet and apply it at some later time, fetch a JavaScript asset and execute it later, and so on. Preload fetches do not block the document load event and allow the application to determine which resources are applied, when they are executed, and in which order.

Defer: The "defer" preloads during HTML parsing and will only execute it after the parser has completed.



我无法理解这两个概念的差异。两者都在不阻塞解析器的情况下异步获取内容,然后在解析器完成后都可以执行。

那么有什么区别吗?

最佳答案

预加载提取不会阻止文档加载事件,并允许应用程序确定应用了哪些资源、何时执行以及以何种顺序执行。 Defer:“延迟”在 HTML 解析期间预加载,并且仅在解析器完成后执行。

关于javascript - 延迟脚本与预加载链接有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60933337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com