Javascript files in a production environment

I am moving from a development environment to a production environment and would like to know the best way to handle javascript/jquery files on the production server. I have looked at Packer and also searched this forum for ideas but the only threads I came up with were a year old and I would prefer some comments more recent than that I think.

Obviously I would at the very least like to strip out comments, etc. and would also like to minimize them as much as possible if that makes a performance difference. Any input is welcome at this point.

Thanks

If you look at jQuery you will notice that they abandoned using Packer some time ago and now just use a minified version with the comments and surplus spaces stripped out.

The reason is that it is far more efficient to use the compression facilities that the server and browser provide that allow gzipped versions of the files to be sent rather than trying to build further compression into the JavaScript itself and the gzipped minified jquery file is as small as the gzipped Packed version would be without the need to run JavaScript in the browser to unpack it.

Not using Packer (or any other JavaScript compression functionality that requires JavaScript to decompress the script) results in a significant increase in performance.

Thanks for the input. Not sure we’re on the same page. I am talking about my js files that I’m wondering about my files that I am including as

<script type="text/javascript" src="/js/common.js"></script>

I found a Minify routine that seems to work fine. Is it necessary to do more than that? The files aren’t all that big, the largest is 20k that minifies to about 13k. Is it even worth worrying about?

The minify does remove all the comments, etc. which is nice.

Well that should help make your page load faster and so is worth doing.

The point I was trying to make is that minifying all your scripts is worthwhile. Trying to compress them using Packer or similar is not worthwhile because while doing that can make the file slightly smaller it means that there code that needs to run after the page has been downloaded to unpack the script back into code that can actually run.

Since most browsers and servers now support the downloading of gzipped versions of the files the actual amount of data to be sent from the server to the browser will be less than the original file size. So your minified js file may only actually need to send 8k to the browser in order to download the 13k script whereas if you used Packer the 20k script might compress down to 10k which then gzips to 9k to send to the browser and then still needs to beunpacked before it can be run (all file sizes are estimates and would vary depending on the actual content of the script but this should give you the general idea).

So short answer - yes use the Minify routine that you have found as minifying JavaScript is currently the most efficient way of delivering the script to the browser.
Basically minifying your JavaScript is worth doing because it gets rid of the comments and so saves bandwidth. It also strips out all the unnecessary whitespace making the script harder to read which will also have some impact on the bandwidth (since gzipping the file using settings on your server will compress out a lot of the whitespace anyway).

Anything that will require running a script in the browser in order to convert the code back into something that can be run as JavaScript (such as using Packer) is not worth doing since any saving in file size on the server does not result in any significant saving in the amount of data that needs to be sent to the browser and it does slow the processing of the script once it is downloaded.

Thank you so much. That makes it perfectly clear and was the exact input I was looking for. I really appreciate it.