나는 minifier가 이것으로 시작하면 어떤 메소드 나 프로퍼티도 대체하지 않기 때문에 prototypical javascript로 그 좋은 것을 수행하지 않는다는 것을 알았다. 예를 들어 :javascript optimization and minification vs gzipping
// unoptimized 182 bytes
myClass.prototype.myFunction = function(){
this.myElementDom.style.backgroundColor='#000';
this.myElementDom.style.color='#FFF';
this.myElementDom.style.borderColor='#DDD';
}
// 168 bytes = 92% of unoptimized, YUI compressed
myClass.prototype.myFunction=function(){this.myElementDom.style.backgroundColor="#000";this.myElementDom.style.color="#FFF";this.myElementDom.style.borderColor="#DDD"};
// optimized 214 bytes
// set a replaceable local scope variable and reduce 2 variable
// lookups at the same time
// file-size in the development version doesn't matter, so we can even increase it
// to preserve readability
myClass.prototype.myFunction = function(){
var myElementDomStyle = this.myElementDom.style
myElementDomStyle.backgroundColor='#000';
myElementDomStyle.color='#FFF';
myElementDomStyle.borderColor='#DDD';
}
// 132 bytes = 72.53% of unoptimized, YUI compressed
myClass.prototype.myFunction=function(){var a=this.myElementDom.style;a.backgroundColor="#000";a.color="#FFF";a.borderColor="#DDD"};
만세은 19.47 % 저장 ...하지 ... 활성화 GZIP으로 스크립트, 분명히 130 바이트 (= 최적화되지 않은에서 71.42 %)과 함께 최적화되지 않은, YUI 압축 된 버전의 부하를 게시 할 때하는 것은 얻는다 134 바이트 (최적화되지 않은 것에서 73.63 %)의 최적화 된 YUI 압축 버전보다 더 많은 절감 효과가 있습니다. 압축이 작동하는 방식을 생각한 후에 분명할지 모르지만 지금 갈 방법이 있습니까? 처음에는이 마이크로 최적화와 작은 압축을 사용하여 gzip으로 더 큰 파일 크기를 정당화 할 수 있습니다. 그런 최적화로 코드를 쉽게 읽고 관리하기 쉽도록 만들 수 있습니다. 그것으로 오지해야 http://refresh-sf.com/yui/
google closure minifier를 사용할 수 있습니다. 또한'gzip' +'minify'는 여전히'gzip'보다 낫습니다. – kirilloid
두 번째 예제는 공간 절약을 찾기보다 런타임에 DOM 조회를 줄이는 방법에 관한 것이 아닙니까? –