|
|
|
|
|
by Klathmon
3369 days ago
|
|
I use uglifyjs and it does a pretty good job of it. We use blocks like this throughout our codebase: if (process.env.NODE_ENV === 'development') {
fancyDebuggingFunction(stuff)
}
// ... some code later
fancyDebuggingFunction(var) {
/* do debugging things here */
}
And when combined with some stuff that sets the process.env.NODE_ENV (not sure how that part works honestly, never really looked into it) it will remove not only the if statement, but also the function if it's not called anywhere and not exported.Throw in Webpack 2's import/export bundling stuff, you can exclude whole modules which you don't use in production which can really reduce the size of your code. And moving forward if the JS ecosystem can ever get a handle on a good way to move to import/export by default, you'll start seeing massive gains in this area by being able to strip out any parts of a library that you don't use. Also, I believe most widely used minifiers use AST parsing to do their work. |
|