CodeIgniter Forums
How to concatenate and minify JS files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: How to concatenate and minify JS files (/showthread.php?tid=67263)



How to concatenate and minify JS files - ldetomi - 02-02-2017

Hi folks,
I'm sorry if I'm asking a trivial question but I'm not an expert...

I have many JS files into my website that must be loaded into a single page. I know that generally is possible to concatenate and minify all files to make a single call to webserver but my question is:

Is possible to concatenate and minify JS files in CodeIgniter or more generally, how can I achieve this result? For more informations I have a webserver in which is not present Node.JS.

One alternative that I know is concatenate files with a 3rd party tool and then add a custom option in CI config to decide if files must be loaded one by one or the single merged but it would be a complete custom (and manually) procedure...


RE: How to concatenate and minify JS files - muyassarov - 02-02-2017

Hi there,
I am also interesting how to solve this problem.


RE: How to concatenate and minify JS files - mario - 02-02-2017

Hi,
You can use to minifi js https://github.com/tedious/JShrink
You can simply concatenate minified js strings in PHP and save them to js file.


RE: How to concatenate and minify JS files - usmanikram - 02-02-2017

User Gulp http://gulpjs.com/

Here is a good tutorial: https://www.sitepoint.com/introduction-gulp-js/


RE: How to concatenate and minify JS files - muyassarov - 02-02-2017

(02-02-2017, 09:13 AM)usmanikram Wrote: User Gulp http://gulpjs.com/

Here is a good tutorial: https://www.sitepoint.com/introduction-gulp-js/

Thanks, that is exactly what I was looking for.


RE: How to concatenate and minify JS files - Avenirer - 02-03-2017

..or you can try my library (https://github.com/avenirer/Assetor)...

Haven't updated it for quite some time but no one complained yet. The usage instruction can be found here: https://github.com/avenirer/Assetor/blob/master/USAGE.md