gpt4 book ai didi

performance - Minify,mod_pagespeed...如何处理合并javascript文件

转载 作者:行者123 更新时间:2023-12-03 16:58:48 25 4
gpt4 key购买 nike

在 page1.html 上说我需要 mootools.js 和 main.js ......我猜这些工具应该生成一个缩小的 js 文件(比如 min1.js)。
然后在 page2.html 我需要 mootools.js、main.js 和 page2.js ......这些工具是否提供 min1.js (已经被浏览器缓存)和 page2.js ?或者他们是否结合了这 3 个 .js 文件并提供需要被浏览器再次完全缓存的缩小文件?

谢谢

最佳答案

假设您使用的是 Apache 模块 mod_pagespeed 因为您用它标记了问题但没有提及您是否使用...

如果你打开ModPagespeedEnableFilters combine_javascript (默认禁用),它在整个页面上运行。根据documentation :

This filter generates URLs that are essentially the concatenation of the URLs of all the CSS files being combined.



page1.html 将结合 mootools.js、main.js 和 page1.js; page2.html 将是 mootools.js、main.js 和 page2.js。

那么,要回答您的问题,是的,它会缓存重复的 JavaScript 文件的多个副本。

然而,

By default, the filter will combine together script files from different paths, placing the combined element at the lowest level common to both origins. In some cases, this may be undesirable. You can turn off the behavior with: ModPagespeedCombineAcrossPaths off



如果您保留此行为,并将文件分散在您想要组合的路径中,您可以将它们分开,以便将公共(public)脚本组合为一个,而单独的脚本将自行组合。这将减少大型通用库的重复。

关于performance - Minify,mod_pagespeed...如何处理合并javascript文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6865402/

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