gpt4 book ai didi

JavaScript 性能

转载 作者:行者123 更新时间:2023-11-28 11:13:50 29 4
gpt4 key购买 nike

我刚刚在我拥有的临时网站上收到了以下反馈。

There are over 100 lines of JavaScript code [in the footer] which should be in a separate file for performance, not in the markup.

尽管我的印象是,在页脚中提供它可以提高性能,因为它减少了一个 http 请求。

对于生产环境,哪种方法更好(内联或外部)?

最佳答案

将 JS 保存在外部文件中可以在页面之间缓存和重用(或重新加载同一页面)。

首次加载时会有一个小的性能损失,以换取 future (相对)较大的增强。

关于JavaScript 性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7649720/

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