I’m testing google closure-compiler and wanting to compile facebox Plugin with the option “Advanced” , an error occurs the function trying to find “a.H”.
Has anyone tried to compile with this option jQuery plugins with a good result.
Thank you.
EDIT:
Clearly this re-naming the jQuery methods, but is it possible to include jQuery and re-name all methods equally?.
EDIT
example of code with the option “externs_url”:
js input code
// ==ClosureCompiler==
// @output_file_name default.js
// @formatting pretty_print
// @compilation_level ADVANCED_OPTIMIZATIONS
// @warning_level QUIET
// @externs_url http://code.jquery.com/jquery-1.5.min.js
// ==/ClosureCompiler==
// ADD YOUR CODE HERE
var test = function($, context) {
var
_self = this;
_self.mymethod = function() {
var lista = $("a", context);
lista.attr("target", "_blank");
return lista.html();
};
return {"mymethod":_self.mymethod};
}.call({}, jQuery, context);
js ouput code
(function(b, c) {
this.a = function() {
var a = b("a", c);
a.attr("target", "_blank");
return a.html()
};
return{mymethod:this.a}
}).call({}, jQuery, context);
I encountered the same issue when trying to compress a custom JS library of jQuery Plugins. Closure (unless you give it a reason not to) will just rename any jQuery library calls from within your plugin. And worse yet it will not even warn you (how could it? it assumes you the programmer know what you are doing!) the solution is to reference the external js file (or url points to the library). I used the web tool:
http://closure-compiler.appspot.com/home
by applying the fowlloing preamble, i was able to compile the file successfully:
The only issue remaining is making the compiler realize that the plugins name, cannot be simplified:
Because this is the name exposed to the world. Any ideas?