Hacker News new | past | comments | ask | show | jobs | submit login

>With javascript in the browser you can see and experience code-reload after an F5†. There is no compilation time; no real detriment to importing another non-used library if it's not compiled into your code.

While that may be true, typical JavaScript projects require a compilation step. Plain JavaScript is starting to get somewhat rare, and projects typically use a compile-to-js language like CoffeeScript or TypeScript, or perhaps ES6-to-ES5 compile step. And then you need to minify that code since it's not recommended to run a non-minified "debug" version during development. And if you're project is any complex you're probably also compiling a single .css file perhaps from .less, compiling .html from .jade and packaging it all up in a different public folder.

The point is that typical non-trivial web applications need a build step.




Why would you minify your code during development? Isn't minified code for production?


Because minified code functions differently from non-minified code. It helps to detect bugs caused by minification. There's also a general principle which states that the application shouldn't be developed in a "debug" mode, because the debug mode might cause the application to execute differently from production.


As I understand it, minification is basically removing whitespace. Why would that make the code behave differently?


Minification can also involve changing variable names; sometimes there are dependencies on names that are unknown to the minifier. Also, the removal of whitespace can cause lines to combine in interesting ways if there aren't semicolons between them and if the minifier doesn't automatically add it.

http://stackoverflow.com/search?q=minification+bug


JavaScript minifaction is much more than that. It renames function parameters, does all kinds of fancy tricks to refactor code and so on. AngularJS is one example where minifacation breaks the code if you don't use the "special" minification-safe pattern.


On the off chance that whatever minification library you're using broke something somehow.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: