gpt4 book ai didi

php - 在 php 中合并和压缩多个 JavaScript 文件

转载 作者:可可西里 更新时间:2023-11-01 02:00:54 25 4
gpt4 key购买 nike

我正在开发一个需要八个 javascript 文件的 PHP 应用程序 (hello web2.0)。

我想知道动态组合和压缩所有文件的最佳方式是什么。我对问题的措辞是否正确?

最终结果是我将在 header 中包含一个 .js 文件,而该 .js 文件将包含我的“includes/js”目录中的 .js 文件。

谢谢。

最佳答案

您可以使用 jsmin-php

他们的示例代码是:

require 'jsmin-1.1.1.php';

// Output a minified version of example.js.
echo JSMin::minify(file_get_contents('example.js'));

您可以通过执行以下操作轻松加入多个 js 文件:

require 'jsmin-1.1.1.php';

// Output a minified version of example.js.
echo JSMin::minify(file_get_contents('example.js') . file_get_contents('example2.js'));

关于php - 在 php 中合并和压缩多个 JavaScript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/868857/

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