53800

YUI Compressor: What are micro optimizations?

Question:

YUI Compressor, in its (not very extensive) documentation states this as an option:

--disable-optimizations Disable all the built-in micro optimizations.

Does anyone know what this means?<br /> What will this turn on/off?<br /> I haven't found any documentation about it.

Thanks!

Answer1:

Looking at the source of JavaScriptCompressor:

<a href="https://github.com/yui/yuicompressor/blob/master/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java#L548" rel="nofollow">lines 548</a>-

if (!disableOptimizations) { optimizeObjectMemberAccess(this.tokens); optimizeObjLitMemberDecl(this.tokens); }

<a href="https://github.com/yui/yuicompressor/blob/master/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java#L467" rel="nofollow">lines 467</a> -

/* * Transforms obj["foo"] into obj.foo whenever possible, saving 3 bytes. */ private static void optimizeObjectMemberAccess(ArrayList tokens) {

<a href="https://github.com/yui/yuicompressor/blob/master/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java#L497" rel="nofollow">lines 497</a> -

/* * Transforms 'foo': ... into foo: ... whenever possible, saving 2 bytes. */ private static void optimizeObjLitMemberDecl(ArrayList tokens) {

So it's converting use of constant strings in foo['bar'] to foo.bar and {'bar':x} to {bar:x}.

Recommend

  • macOS Mojave, Automator “Not authorized to send Apple events to System Events.”
  • How can I create new folder/file with javascript?
  • Validating JSON before deserializing into C# object
  • How to make Views overlap each other by a specified amount?
  • Storing vector XNA Animations
  • The ViewBag content isn't being visualized
  • sorting based partition (like in quick-sort)
  • What are some common WMI queries
  • Map a DiskIndex to a Volume Label
  • How to remove the box frame in “plot.raster” in R package “raster”
  • YUI Compressor: What are micro optimizations?
  • PHP: imageftbbox
  • Minimum API for implementing Android Deep Linking
  • how to make a non-hardcoded URL path in docker image to call backend service?
  • Ensuring an assembly is called via a specified assembly
  • Button needs to be clicked twice to trigger function
  • clock_gettime() still not monotonic - alternatives?
  • Silverlight xaml TextBlock.Text with CDATA not showing up at runtime?
  • Google Apps Script GmailApp - Label threads include off-label messages
  • jquery validation - waiting for remote check to complete
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • Read text file and split every line in MSBuild
  • jQuery show() function is not executed in Safari if submit handler returns true
  • Does CUDA 5 support STL or THRUST inside the device code?
  • javascript inside java/jsp code
  • WinForms: two way TextBox problem
  • Javascript + PHP Encryption with pidCrypt
  • When should I choose bucket sort over other sorting algorithms?
  • Websockets service method fails during R startup
  • Adding custom controls to a full screen movie
  • How do you troubleshoot character encoding problems?
  • Return words with double consecutive letters
  • how to add data labels for bar graph in matlab
  • How to disable jQuery.jplayer autoplay?
  • Proper folder structure for lots of source files
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Understanding cpu registers
  • -fvisibility=hidden not passed by compiler for Debug builds
  • How can I remove ASP.NET Designer.cs files?
  • Net Present Value in Excel for Grouped Recurring CF