开发者

Minifying Prototype introduces an error?

I have made use of several web based minifiers that have worked for me in the past. I have just tried minifying a prototype version 1.6.0.1 - I have placed the original here and the minified here.

The error I get from firebug after the js file being minified is this:

missing } after property list
ept': 'text/javascript,text/html,appli...estHeaders=='object'){var extras=this.

I don't understand why this has not worked. I have minif开发者_Go百科ied JQuery and it works. This is the first time I have tried minifying prototype, I mean it should work right, its just removing whitespace and comments!

Thanks all for any helo


the minifier you use consider everything between /* and */ as comments, but looking at lines 1244 to 1254 (from the original script):

  'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};

if (this.method == 'post') {
  headers['Content-type'] = this.options.contentType +
    (this.options.encoding ? '; charset=' + this.options.encoding : '');

  /* Force "Connection: close" for older Mozilla browsers to work
   * around a bug where XMLHttpRequest sends an incorrect
   * Content-length header. See Mozilla Bugzilla #246651.
   */
  if (this.transport.overrideMimeType &&

the first /* was inside quotes, it should have left it alone, you should change the * next to ept': 'text/javascript,text/html,appli in your code and paste the missing text, so instead of:

'Accept': 'text/javascript,text/html,application/xml,text/xml,*if(this.transport.overrideMimeType&&

you should have

'Accept': 'text/javascript,text/html,application/xml,text/xml,*/*'};if(this.method=='post'){headers['Content-type']=this.options.contentType+(this.options.encoding?'; charset='+this.options.encoding:'');if(this.transport.overrideMimeType&&

Consider changing the minifier you are using to something less buggy.


I minified your script with yuicompressor, the resulting file is 3K less than the one you have, the minifier you use leave spaces in places they can be omitted. check it here: Prototype JavaScript framework, version 1.6.0.1, minified using yuicompressor


I use minify for one of my projects and I combine prototype, scriptaculous, jQuery and some plugins into one minified file. It works without any error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜