Is there a risk to minify JS and CSS?

I have a complex web application for an embedded system and it will be testing soon. Currently, all files are in their original form for debugging. I absolutely need to minify all JS and CSS and am wondering if there is a chance that something could go wrong. Is it better to test coded code or in original state?

Thank.

+3


source to share


2 answers


If a cosmic ray were supposed to penetrate your build server case and hit memory during minification, it could mess things up. However, the chances of this are very small.

One more step in your assembly will always be tricky and error prone, especially when it modifies a file. As you test, you will find that because you should always test what you plan to deploy for production. If you deploy a minicode, you check the minicode.

Minification is so widely used that most of the tools are quite mature and robust, with excellent accuracy in detecting what is in use and what is not. They are very good at not removing code that is used in an unusual way.



However, it is possible that the minifier decides that something is not being used and is wrong. In this case, testing your device and / or integration should fail and you can change the code or tell the minifier to keep the section that was missing.

These fixes are pretty quick and usually obvious, so the benefits of having a few small files (rather than many large files) almost always outweigh them. Since minifiers significantly rename code or completely remove it, simply testing your application's smoke often enough to spot any bugs.

As an example, the Google closure compiler is a tutorial on handling global and external variables, exports, and unused code that you need to keep.

+5


source


Generally, there is no functional difference between source code and minicode. The minification process should only make safe changes to the code when it is minified.

However, I always say that any system that is complex enough to be really useful also has bugs. Even if it is very unlikely that you accidentally stumbled upon an error in the minicode, it is still possible.



I would recommend that you test the coded code. You can probably run your first tests with unminified code, as it is much easier to debug unprotected code.

+1


source







All Articles