views:

87

answers:

3

Should we test the minified versions of our javascript files as we develop them, or is it an extremely low risk that the minified javascript does not differ in function from the un-minified version?

+5  A: 

Running your test suites against them should be enough.

...

You do have test suites... right?

Ignacio Vazquez-Abrams
You caught me! Do you have any pointers to resources for writing js test suites, especially code that makes use of jquery to manipulate the dom, handle events, etc.?
Readonly
Unfortunately JavaScript is one of the languages that I've not had to write a test suite for yet. JSUnit looks promising though. http://www.jsunit.net/
Ignacio Vazquez-Abrams
A: 

I have not seen any of my scripts behaving differently so far after minifying them but sill i do test them before making them public just to make sure everything has been done correctly.

And you are supposed to sort of test it before using/making it public just to make sure that it works the way you wanted.

If you have done everything correctly in non-minified version, it should be not a problem.

Sarfraz
+4  A: 

Run them through jslint before minifying them and if they pass that they should minify without a problem. The key here is to not forget a ; since minifying will remove all linefeeds. Also declaring variables helps the minifying process, but not doing so will not break anything by minifying.

svinto
Also try to avoid the `a + ++b` type of stuff, as suggested here (in the caution part): http://www.crockford.com/javascript/jsmin.html
Alex Bagnolini