Javascript Minification With Semicolon Insertion
Solution 1:
When I was in a similar situation a couple of years ago, I seem to recall that the solution was essentially "the more the merrier"!
Firstly I ran the script through Dojo Shrinksafe on very modest compression settings. Because it uses Rhino, it would actually interpret the JS and then write out an equivalent version with syntactically correct semicolons.
From there, I fed the output into Dean Edward's /packer/, which (at the time, at least) was the highest-compression library that produced consistently functional output. This library requires the input to have semicolons, but that wasn't a problem thanks to the output from ShrinkSafe.
(Note that this is from memory and I haven't tested it recently, but there's no reason why the principle shouldn't hold any more. If ShrinkSafe doesn't insert semicolons for you, perhaps there's some other JS-preprocessing tool that will automatically do this? Modulo, of course, the fact that semicolon insertion is not 100% deterministic).
Post a Comment for "Javascript Minification With Semicolon Insertion"