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.