views:

65

answers:

2

Hello all,

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 minified 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

A: 

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.

Kau-Boy
That is very useful, but I am hoping to solve my error now.
Abs
Is there any reason you use the old 1.6.0.1 version and not the new one which can be minified without any errors?
Kau-Boy
@Kau-Boy - yes, I have to use this version as I have done a lot of work on it. Using the newer version breaks my app. Are you saying the new one can be minifed and not the older one I am using??
Abs
There are some prototype versions that have know issues when minifying them. Unfortunately, I don't have a copy of prototype 1.6.0.1 anymore. Do you know where to download it? I could than test my minifier to minify it.
Kau-Boy
I have linked it in my question, the first link is the original.
Abs
+3  A: 

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

aularon
Thank you very much for explaning the problem and solving it! I'll use yuicompressor from now on too!
Abs