0

I have built a customized php framework.

I have a view, controllers and model.

In the view, there is variable which i can set.

$js = array('custom/testimonial.js','jquery.js');

At the footer view i have the following code.

-------------------------------------------------*/
if(isset($js)){
foreach ($js as $jsname) { ?>
<script src="<?php echo MAIN_URL; ?>/resources/js/<?php echo $jsname; ?>"></script>
<?php 
} 
}

Basically, the code in footer will load all the necessary scripts required for that page. In my other pages, i have other(different) javascripts files to include. This mean thats each page will have different javascript.

I would like to minify the js for each of the page and wonder which is the best way. I tried using Assetic (php asset management) with no luck.

Another question is should i minify javascript on the fly? Means when i load my page called testimonial.php it will check what are the javascript required for the page and minify them before displaying. Will that post performance issues even if i cache it.

I am looking for some methods that has high maintainability as i do not have to minifiy all javascript manually, have 40 to 50 plus pages. (each page uses different javascript files, plugins, lib).

Can Assetic do the job for me? Currently i have problems generating a static file for the javascript.

Appreciated any help.

4

1 回答 1

0

雅虎 (YUI) 曾经有一个压缩器/压缩器,但他们现在正在转向 UglifyJS。看:

还有一些基于 YUI 压缩器的在线缩小服务。

于 2013-07-26T03:55:02.483 回答