Last modified: 2012-12-02 07:59:20 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T36905, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 34905 - JavaScriptMinifier: Skip '+' when both side is a literal
JavaScriptMinifier: Skip '+' when both side is a literal
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.20.x
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-02 20:50 UTC by db [inactive,noenotif]
Modified: 2012-12-02 07:59 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description db [inactive,noenotif] 2012-03-02 20:50:50 UTC
Sometimes a javascript literal has a break to add a manually newline or to break wikisyntax (like signature, the tracking of cats and templates of script pages was changed in 1.19, but many scripts are using that in production), but in that case it is possible for the minifier to skip the quotes and the plus and save three bytes.

For the javascript literal with slash at the end the minifier can change that to a single literal to save two bytes (slash and newline).

"te"+"xt"
=> "text"

"te          /
xt"
=> te          xt"

Only when someone has fun to do it. Thanks.
Comment 1 Trevor Parscal 2012-03-03 00:00:38 UTC
If you look at libraries like UglifyJS[1], there are a lot of optimizations that can be done without using Google Closure Compiler. That said, we need to be careful because while these optimizations appear to be safe, if there's anywhere on the web we can prove that wrong it's likely to be on Wikipedia with it's abundance of core, extension, site, user and gadget scripts all running together.

[1] https://github.com/mishoo/UglifyJS
Comment 2 Krinkle 2012-03-05 08:41:57 UTC
I think there's also something to be said for the minifier sticking to minifying and not actually changing javascript code (no matter how redundant it may seem).
Comment 3 db [inactive,noenotif] 2012-03-05 17:29:01 UTC
(In reply to comment #2)
> I think there's also something to be said for the minifier sticking to
> minifying and not actually changing javascript code (no matter how redundant it
> may seem).

That it right, but bug 31286 is also for minify and must change the javascript a bit. Feel free to make the bugs as WONTFIX or so, if you think, that is not good inside a minifier.
Comment 4 Krinkle 2012-12-02 07:59:07 UTC
Marking bugs that suggest altering the token stream in JavaScriptMinifier as wontfix.

If we decide to go that way, it is probably best to use existing libraries such as UglifyJS which are much more advanced at this.

We aren't doing that yet because of the performance penalty involved with iterating over the token stream and reformatting it (since we do all of this on-demand on production servers).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links