开发者

JavaScript minifier that strips out unused code

开发者 https://www.devze.com 2022-12-13 23:24 出处:网络
Does anyone know of a JavaScript minifer that can detect unused code and strip it out. Google Closure seems alright but it appears to only compact.

Does anyone know of a JavaScript minifer that can detect unused code and strip it out.

Google Closure seems alright but it appears to only compact.

I'm looking for something much more advanced, where it can look through my JavaScript and not only compact but also remove unused code.

Anyone know of such a tool?

The use base being, I use开发者_如何学运维 very little functionality of JQuery - what I would like to do is remove from the base/core all the bloat that is unneeded from my use.


Closure Compiler should do the job, from the Closure FAQ

Closure Compiler helps reduce the size of your JavaScript by removing comments and unused code and shrinking the remaining code.


Probably not.

The problem is that there's no guaranteed way to figure out what's used and what isn't. Javascript can be used/referenced from HTML, the script(s) could be used with other unknown scripts that use otherwise unused code and eval() blocks may use things you don't realize.

Minify and gzip it and that's enough. If not, cull it by hand (although getting rid of code is a lot harder than adding it in the first place).

0

精彩评论

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