Netlify Minify
Wed, Aug 21, 2019if you use the service Netlify for a static site you get the option of doing automatic minification of your javascript when the site is deployed.
Its as easy as setting a checkbox.
I recently used on a site, and to my surprise it did not work (since Netlify usually works like a charm)
After doing some back and forth with Netlifys support and trying the advice in this post it still did not work unfortunately.
In the site I was testing I had several scripts and none of them where minified.
Then I turned to good old binary search to find the cause of the problem, i.e. removing half of the code then testing again, etc.
It turns out that Netlify uses a very sensitive minification algorithm (which is custom made according to the supporter I talked to).
- If it fails for one script the minification does not run for any script.
- In my case I had two scripts that failed,
- I had an object that had 2 consecutive kommas by mistake. Apparently that javascript was accepted by the browser but not by the minifier.
- I also had a script that uses the const keyword - apparently not accepted by the minifier.
Netlify is all in all an impressive service, but it is helpful for you to know quirks as the above.
And since their minifier is custom made it is not possible to test it on your own machine.