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?
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?
Share Improve this question asked Feb 21, 2010 at 10:00 readonlyreadonly 356k109 gold badges206 silver badges206 bronze badges4 Answers
Reset to default 7Running your test suites against them should be enough.
...
You do have test suites... right?
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.
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.
It depends on what you minify with. Closure Compiler and YUI Compressor fully tokenize and parse scripts and tend to handle almost anything most browsers will accept. JSMin (particularly modified versions) are mostly reliable, but stay away from anything regex-based.
Agreed on svinto's advice.