Bug Tracker

Ticket #7318 (closed feature: wontfix)

Opened 4 years ago

Last modified 3 years ago

Support Closure Compiler ADVANCED_OPTIMIZATIONS

Reported by: cjavapro@… Owned by:
Priority: low Milestone:
Component: misc Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:

Description

If I paste jQuery minified code to the top of my JS file and my code to the bottom, It works fine uncompiled.

If I use closure compiler in simple optimizations it works fine

I want to be able to use advanced. That would allow some of the unused jquery functions to be stripped out altogether!! AND the ones I use would be shortened!!

Unfortunately.. in 1.4.2 mouseout is stripped out whether I use it or not and in 1.4.3 I get an error within the jquery code that exec is not defined.

Change History

comment:1 Changed 4 years ago by snover

  • Component changed from unfiled to misc
  • Summary changed from I want to be able to use Google Closure Compiler ADVANCED_OPTIMIZATIONS to Support Closure Compiler ADVANCED_OPTIMIZATIONS
  • Priority changed from undecided to low
  • Milestone 1.5 deleted
  • Keywords needsreview added
  • Type changed from enhancement to feature

I’m not sure if the effort to support ADVANCED_OPTIMIZATIONS is worth the size benefits it might provide, but we’ll take a look.

comment:2 Changed 4 years ago by dmethvin

More info about advanced optimizations:

 http://code.google.com/closure/compiler/docs/api-tutorial3.html#dangers

Doesn't seem worth the effort to me.

comment:3 Changed 4 years ago by snover

  • Status changed from new to closed
  • Resolution set to wontfix

Nope; the ability for people to duck punch most of the jQuery functions to enhance functionality means this wouldn’t work properly for standalone jQuery files, and writing code to conform to Closure Compiler’s ADVANCED_OPTIMIZATIONS mode is a huge undertaking that very few people will actually bother to do.

I’m also fairly confident that our expando-generating stuff (the code that generates the bind-alias methods like .click) will never work properly, and it’s looking increasingly likely that we are going to start using UglifyJS for minification in the future since it results in smaller code.

comment:4 Changed 4 years ago by dmethvin

  • Keywords needsreview removed

comment:5 follow-up: ↓ 6 Changed 4 years ago by andrearo@…

I would really like to see the advanced mode of Google Closure Compiler supported. It would be useful for my project.

comment:6 in reply to: ↑ 5 Changed 4 years ago by cjavapro

Replying to andrearo@…:

I would really like to see the advanced mode of Google Closure Compiler supported. It would be useful for my project.

It would be a large decision for them to do this (I wish they would). Every single name would have to be either variable form

$.animation = {swing: function () {...}}

or string form

$['animation'] = {'swing': function () {...}}

This would have to be

  1. considered for every item

and

  1. maintained ongoing

I would expect animation can be renamed and swing cannot

$.animation = {'swing': function () {...}}

comment:7 follow-up: ↓ 8 Changed 4 years ago by ajpiano

It’s looking increasingly likely that we are going to start using UglifyJS for minification in the future since it results in smaller code.

We've since switched to UglifyJS, so this is a moot point at this point

Version 0, edited 4 years ago by ajpiano (next)

comment:8 in reply to: ↑ 7 Changed 4 years ago by cjavapro

Replying to ajpiano:

It’s looking increasingly likely that we are going to start using UglifyJS for minification in the future since it results in smaller code.

We've since switched to UglifyJS, so this is a moot point at this point

I would say just because you use UglifyJS, that does not mean that you cannot support Closure Compiler.

There is the risk that the changes would cause UglifyJS to be less effective. I do not know.

comment:9 Changed 4 years ago by ajpiano

#8463 is a duplicate of this ticket.

comment:10 Changed 4 years ago by jzaefferer

The discussion here in regards to what is necessary to support Closure Compiler is at least incomplete, more likely just wrong. See  http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/jquery-1.5.js

jQuery could never distribute a minified version via advanced mode (that just makes no sense in this context), but maintaining the externs file and documenting how to use it to minify application could be a very good answer to the "jQuery is too big" problem.

comment:11 Changed 4 years ago by cjavapro@…

@jzaefferer

The discussion here in regards to what is necessary to support Closure Compiler is at least incomplete, more likely just wrong

I know this is a sloppy conversation, but I think I am able to defend and explain any of the comments I have made.

jQuery could never distribute a minified version via advanced mode

That is obvious for those who understand advanced mode. The reason is that jQuery and the application's code are supposed to be minified together. The distributed minified version can stay as UglifyJS, the one for advanced mode would stay unminified because it would take advantage of advanced mode when the time comes.

maintaining the externs file and documenting how to use it to minify application could be a very good answer to the "jQuery is too big" problem

The externs file will allow us to use jQuery in our code which is already configured for advanced mode, but it will not make jQuery any smaller. Only advanced mode would allow removal of all unused jQuery functions, excluding the ones that are written in string style, for example $['click'] = function(...){...}.

comment:12 Changed 3 years ago by linzuxiong1988@…

It is too difficult that using the advanced mode of Google Closure Compiler . If the externs are using jquery-xx.min.js , Closure Compiler reports many error....

comment:13 Changed 3 years ago by anonymous

yes, it would be great if the jQuery team could provide an official "externs" file, like the one linked above. Closure (Compiler, Templates, Library, ...) is an amazing value for the JS community. I would expect most Closure users to use its "goog.dom" components, but JQuery could very well live in many projects.

comment:14 Changed 3 years ago by Michael Rienstra <mrienstra@…>

Note that there is a similar ticket which is open (at the time of this writing) . See #11015, "Integrate with Closure Compiler". This ticket also appears on the 1.8 Ticket Vote. Hope springs eternal! :D

Note: See TracTickets for help on using tickets.