2014-09-20 31 views
0

大家好我有使用JSMin缩小JavaScript PHP函数,但我希望有一个正则表达式与a或b缩小JavaScript有效地使用PHP

function foo(long_arg_name, long_arg_name2){ alert(long_arg_name + long_arg_name); }

更换 长参数名称

function foo(a,b){ alert(a+b); }

+0

你并不总是得到什么你要。 – 2014-09-20 12:36:53

回答

0

您可以使用此插件:

https://github.com/promatik/PHP-JS-CSS-Minifier

它使用该minifier http://javascript-minifier.com/

,或是使用 http://javascript-minifier.com/examples

这个脚本
<?php 
    // setup the URL, the JS and the form data 
    $url = 'http://javascript-minifier.com/raw'; 
    $js = file_get_contents('./public/ready.js'); 
    $data = array(
     'input' => $js 
    ); 

    // init the request, set some info, send it and finally close it 
    $ch = curl_init($url); 

    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    $minified = curl_exec($ch); 

    curl_close($ch); 

    // output the $minified 
    echo $minified; 
?> 

不要忘了缓存的一切:)