Loading ...
Sorry, an error occurred while loading the content.

40276Re: YUI Compresser could produce shorter output

Expand Messages
  • crlender
    Nov 2, 2008
      --- In ydn-javascript@yahoogroups.com, Philip Tellis <philip@...> wrote:
      > Try this code:
      > if (map.hasOwnProperty(k)) {
      > if (!(k in target))
      > target[k] = map[k];
      > else
      > target[k] = null;
      > }

      Just tested it, and it works just as expected.

      > It's still one statement inside the outer if, but if you remove the
      > braces, you confuse the engine. Take out the semi colons for more fun.

      No, it's *two* statements inside the outer 'if'. And those semicolons
      are not optional, so taking them out *would* be a syntax error without
      line breaks.

      I'm not sure what you mean by the engine getting confused... I've
      never seen a JavaScript implementation that couldn't correctly parse
      control structures with or without redundant curlies. This is basic
      stuff. Or maybe did you mean the compressor engine could get confused?

      > In any event, what you're stating is a micro-optimisation that buys you
      > nothing if you also gzip your javascript before serving. All those
      > braces will compress into a single bit or something of that order.

      Sure, it's not that big a deal, but the compressor's output *could*
      be improved (even if only by a few hundred bytes per script) without
      sacrificing code integrity. Whether the developers choose to implement
      it that way is of course their choice.

      Regarding gzip: if we could just assume that gzip were universally
      available and supported, the compressor wouldn't have to go to all
      the trouble... just strip out comments and let gzip do the rest.

      - Conrad
    • Show all 15 messages in this topic