Worried you’ll miss us?
Subscribe to get our articles and updates in your inbox.
- You can pull in any combination of the above three file types and combine and compress them into the same file.
- You can optionally output pre-gzipped versions of your files in case you are using a CDN which does not support gzipping files natively. This way you can direct users to the gzipped files if their browser supports it.
This would actually just output the contents of myfile.js into combinedfile.js because we aren’t specifying a tool with which to perform the minification. If we wanted to use jsmin we could specify it by passing the "–min=" parameter:
And if we wanted to pull in a file, a directory, a url, and then compress all of it using the Google Closure compiler (which requires Java to be installed and on the path) we could do this:
And remember, when we pull in that directory we might want to specify the order in which we concatenate the files. We can do this by adding a file called ordering.txt and placing it in the directory. It might look something like this:
Overall I’d like to keep this utility fairly simple, and with a few minor exceptions it already fills the needs that I set out to fill. So, what are those exceptions, what features do I want to add to it?
- More console output (with quiet option). It doesn’t really tell you what it is doing currently.
- Error handling. It doesn’t really check much right now.
- Ability to specify file masks when pulling in a directory.
- Use a config file to specify files, compression methods, etc… instead of passing items as command line parameters. I think this would give a bit more flexibility.
- Implement the YUI Compressor.
- Combine and compress css files as well.
- Maybe have an option to pull in standard libraries. Not sure how to work this out with versioning though.
- Anything great ideas that you guys have!
I hope that if you get a chance you’ll check it out and let me know what you think. Also, if you have any great ideas for changes to make, or you want to help out, please leave a comment! Thanks!
Loved the article? Hated it? Didn’t even read it?
We’d love to hear from you.