Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do you do to your JavaScript code before deployment?

Do you have a step in your deployment process that minifies JS? Do you have any sort of preprocessor for your JavaScript that allows you to leave in comments and console.logs and then have them automatically stripped out? Is your JavaScript machine generated by GWT or Script#? Do you use ANT or another tool to automate deployment?

I see a lot of JavaScript that looks like it comes right out of the editor, complete with lots of white space and comments. How much of that is due to not caring about the state of the deployed code, and how much is due to the spirit of the open web?

like image 747
Nosredna Avatar asked Jun 04 '09 18:06

Nosredna


People also ask

What happens when code is deployed?

Deployment is the mechanism through which applications, modules, updates, and patches are delivered from developers to users. The methods used by developers to build, test and deploy new code will impact how fast a product can respond to changes in customer preferences or requirements and the quality of each change.


2 Answers

I usually check it out with JSLint to make sure it is bug-free, then pack it/encode it with YUI compressor.

like image 62
koni Avatar answered Nov 16 '22 04:11

koni


My steps include:

  1. I write Javascript using TextMate with the Javascript Tools bundle installed. This JSLint's my files on every save and notifies me when errors occur.
  2. I use Sprockets to automatically concatenate my various Javascript files.
  3. I run the resulting concatenation through jsmin to generate a minified version.

I end up with a concatenated lib.js file and a minified lib.min.js file. One I use for development, one for production. TextMate commands help automate it all.

I'm still looking for a good solution to actually (unit) test my scripts.

like image 42
avdgaag Avatar answered Nov 16 '22 04:11

avdgaag