开发者

Extra minification of Javascript under certain assumptions?

开发者 https://www.devze.com 2023-02-13 13:45 出处:网络
Following a previous question, I realize why it\'s not possible to generically minify properties of objects. But what if I can safely assume that certain properties are never ever going to be accessed

Following a previous question,

I realize why it's not possible to generically minify properties of objects. But what if I can safely assume that certain properties are never ever going to be accessed using the obj['propNam开发者_开发百科e'] notation? This should make it possible for the minifier to change the name of the property.

Current minifiers however don't seem to have this option so can this be implemented before the minifier using some simple simple script (sed or even perl) ?


It has nothing to do with using square bracket notation. Those minifiers simply don't know what code has access to obj, so if some code tries to access obj.propName, but the minifier changed that property name, the code will break.

I left an answer to your previous question showing that the "Advanced" optimization feature of Google Closure Compiler does what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号