3 ms·
Define "faster." GZIP creates a smaller file size, but the benefit of minification is faster parsing by the Javascript engine -- GZIP does nothing to help with
by cwyers 11y ago
Define "faster." GZIP creates a smaller file size, but the benefit of minification is faster parsing by the Javascript engine -- GZIP does nothing to help with this.
- ape4 11y agoMaybe not always. Minifiers optimize for space. So they might turn "false" into "!1". Not sure that executes faster.
- jhgg 11y agoUglifyJS does a lot of dead code elimination. Lots of stuff that only runs on dev environments isn't even included in the production build. Stuff like: if (process.env.NODE_ENV !== 'production') { invariant(x, y); console.info(z); }
- BinaryIdiot 11y agoSo yeah they optimize for space but they also optimize for execution. For example the closure minifier literally puts everything on one line, without semicolons (where possible) and uses commas which forces the JavaScript engine to execute it as a single statement which can be faster. That's just a minor point but it can help with speed. Is it enough of an optimization that it's worth it though? I'm not sure; I haven't seen much in the way of benchmarks in this area.