Problems with Prototype 1.7

Feb 7, 2012 at 3:01 PM

I own a bundling/minifying/spriting project https://github.com/mwrock/RequestReduce and I have a user who has run into issues when Using Prototype 1.7. I don't want to post his code but essentially something is not working in the Class method wrapping. I've spent some time looking at the minified vs. unminified acode and I'll admit that I have not pinpointed EXACTLY where things go wrong other than it is somewhere in the prototype class initialization where the wrapped class is not having one of its wrapped functions called. I know that's not incredibly helpful info but I'm wondering if anyone else has run into issues minifying Prototype.js 1.7. Its been out for a while so it seems that this may very well have been encountered by someone else. If I leave all the code as is and simply comment out the one line call to the minifier.dll, everything works.

Coordinator
Feb 7, 2012 at 3:25 PM

So is the error happening when minifying the Prototype 1.7 framework, or the customer code that happens to use the Prototype 1.7 framework? And what version of the AjaxMin dll are you currently using?

Coordinator
Feb 7, 2012 at 3:30 PM

Another tip: one of the first things I do when there's an issue with JavaScript code (minified or otherwise) is run AjaxMin.exe against the sources with the -a option. That's the "analyze" feature, and it will spit out a lot of error and warning messages about the code. Can't tell you how many errors I found in source code over the years using that option. Try it on your client's code and make sure there's not any weird issues around the code in question.

Feb 7, 2012 at 3:42 PM

Thanks for that tip Ron. I'll give it a try tonight. I'm minifying both Prototype and my Community member's script bundled together. My current release includes v4.45 of the minifier but I've also tried locally with 4.46 with the same result. After running this through the analyzer I'll report more. Thanks!

Coordinator
Feb 7, 2012 at 3:45 PM

If there's anything I can do to help, please don't hestitate to ask. It's kind of hard for me to figure out what's wrong if I can't see the code and where it's failing, but if commenting out the minification step makes the issue go away, then it does sound like a problem with AjaxMin. I'd really love to know what's going wrong so I can fix it. I did a few quick Bing searches trying to see if anyone else has been having trouble using AjaxMin with Prototype code, but came up empty. 

Feb 7, 2012 at 4:03 PM

Will do. If the analyzer doesn't show anything I can provide some code that removes the user's business code and replaces it with something similar but generic to reproduce. I googled this too so we have covered all major search engines :) and didn't come up with anything either. Thanks Ron!

Feb 9, 2012 at 12:45 PM

Just created Issue 17390 with an attached sample demonstrating a working unminified prototype.js and a minified version that throws an error. Thanks a bunch for looking into this!

Coordinator
Feb 10, 2012 at 9:09 PM

Just to close the loop on this discussion thread, it was discovered that the Prototype library depends on certain functions having the first parameter name be "$super." AjaxMin by default minimizes all variable and parameter names, so it was changing "$super" to something like "n" and thereby breaking the framework and causing script errors. The stop-gap fix was to use the -norename:$super command-line parameter, and with released version 4.46, that no-rename variable was added by default. So minifying the Prototype framework using build 4.46 or higher should now have no issues.