Reputation: 991
Since I've heard people whining how PHP can't handle it, how about minifying JavaScript with JavaScript itself? I want something that I can just copy and paste and use right away--my JS file is about 17KB and I know I can reduce it to about 15KB easily.
And I want to be able to do it right on the server. I don't want to have to go to a website such as jscompress.com every time I make changes to my script.
Again, I would like something like this:
<script type="text/javascript" src="scripts.php?file_to_minify=scripts_template.js"></script>
And then I would just let JS minify it on the PHP file.
Now, I do have second thoughts...Would this even work???
Your help is appreciated. Thanks!
Upvotes: 0
Views: 180
Reputation: 1942
Personally, I would look to have a local version of my site, with all source/configuration files under version control. You could then have a release script that would prepare your files for upload, including minifying your javascript using a command line tool.
This ensures that you don't lose anything if you make a mistake, also it makes build of your site repeatable. This should be requirement for a production site, and is useful for a personal/hobby site (no-one likes losing changes/breaking things with no way back).
Upvotes: 1