在php中组合和压缩多个JavaScript文件 [英] Combining and Compressing multiple JavaScript files in php
本文介绍了在php中组合和压缩多个JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个需要8个javascript文件的PHP应用程序(hello web2.0)。
I am working on a PHP app that requires eight javascript files (hello web2.0).
我想知道动态组合和压缩所有文件的最佳方法是什么。
我是否正确地表达了这个问题?
I am wondering what the best way combine and compress all of the files dynamically. Am I phrasing the question correctly?
最终结果是我会在标题中包含一个.js文件,而.js文件将包含我的includes / js中的.js文件目录。
The end result is that I would include one .js file in the header, and that .js file would include of the .js files in my "includes/js" directory.
谢谢。
推荐答案
你可以使用 jsmin-php
他们的示例代码是:
require 'jsmin-1.1.1.php';
// Output a minified version of example.js.
echo JSMin::minify(file_get_contents('example.js'));
您可以通过以下方式轻松加入多个js文件:
You may easily join several js files by doing something like:
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中组合和压缩多个JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文