Combining and Compressing multiple JavaScript files in php

前端 未结 5 1466
孤城傲影
孤城傲影 2020-12-05 01:07

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. A

5条回答
  •  独厮守ぢ
    2020-12-05 01:43

    You can use jsmin-php

    Their sample code is:

    require 'jsmin-1.1.1.php';
    
    // Output a minified version of example.js.
    echo JSMin::minify(file_get_contents('example.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'));
    

提交回复
热议问题