mklabs/node-build-script

Speed up build process: min task

Opened this issue · 0 comments

The script is pretty fast, node helps a lot here. Overall build times very much depends on the amount of javascript that is going to be minified.

js minificiation is quite costly, blocking and synchronous. Depending on application size and javascript codebase, the min task could easily take more than half of the overall build time, even if there were no changes to these sources.

  1. Manage a local cache of minified script, before / after minification. Compute content hash for pre-min script.
  2. If on subsequent build, the concatenated script that is going through the min task has not changed (by comparing previous sha1 for the file and the current one), then don't re-minify but use the cache version.

This little thing should drastically speed up the build script for mid-to-large sized app (this is handy for times when you're trying out different scripts build target or tweaking the config to see how it goes).


I suspect this to be the same for img optim, with sites with a lot of images. I didn't run into this issue yet though.