When to minify?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorge

    #46
    Re: When to minify?

    On Nov 19, 11:04 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
    wrote:
    >
    OK, so how do you suggest to debug a one-liner that is the result of the
    minifying of, say, 500+ LOCs?  And even if you could do that *always*, I
    seriously doubt you can look at one example of p,a,c,k,e,d code junk and
    tell me at once which identifier in it means which in the original code,
    >(...)
    minified !== obfuscated: JSMin: http://fmarcia.info/jsmin/test.html

    --
    Jorge.

    Comment

    • Thomas 'PointedEars' Lahn

      #47
      Re: When to minify?

      David Mark wrote:
      Thomas 'PointedEars' Lahn wrote:
      >David Mark wrote:
      >>Thomas 'PointedEars' Lahn wrote:
      >>>David Mark wrote:
      >>>>Thomas 'PointedEars' Lahn wrote:
      >>>>>David Mark wrote:
      >>>>>>The answer to "when to minify" is: right before you start
      >>>>>>testing the script. [...]
      >>>>>Right. And when the test fails, you go fix the bug ... wait a
      >>>>>minute, *you can't*.
      >>>>And why on earth not?
      >>>Well, let's say testing shows that there's an error in line 42 of
      >>>the minified code that you want to fix. You could attempt to
      >>>beautify the minified code again and then compare with the original
      >>>non-minified code, but, to begin with, how can you know that even
      >>>the lines numbers are the same then?
      >>[...]
      >>For one, save the original (obviously.)
      >When you can't be sure whether the error that occurred in the minified
      >code also occurs in the original code in the first place, or the
      >problem is the result of the minifying instead, saving the original
      >code is not of much help when finding a problem in the minified code.
      >
      Perhaps you are just snake-bit,
      Sorry, I don't follow.
      but I have never found such an error.
      That does not mean anything.
      Before testing, I run the code through JSLint and then the YUI
      "minifier." Invariably, the code runs exactly as before. If it ever did
      not, I would find the problem easily enough. Thanks for your concern
      though.
      >
      >>For two, who debugs by line number?
      >OK, so how do you suggest to debug a one-liner that is the result of
      >the minifying of, say, 500+ LOCs? And even if you could do that
      >*always*, I
      >
      What difference does it make how many lines of code there are (if you are
      not debugging by line number?)
      The debuggers that I have encountered so far work line-based (e.g., set a
      breakpoint on or go to line #n, not statement #n). There are a few that can
      beautify the code before debugging to make debugging easier (among them
      Venkman), but not all.
      >seriously doubt you can look at one example of p,a,c,k,e,d code junk
      >and
      >
      Nobody, but nobody, uses that stupid p,a,c,k,e,r.
      Experience and Google hits disagree. There are 1'620 Google hits for
      '"p,a,c,k,e, r" javascript", 1'930 for '"p,a,c,k,e, d" javascript'
      as of today.
      What makes you think I use it?
      I did not imply that. You deem yourself to be too important.
      >tell me at once which identifier in it means which in the original
      >code, because obfuscation is one result of this kind of minifying.
      >
      Again, there is no need to track down bugs in the minified code. If
      there ever were, perhaps I would get a new minifier.
      You cannot know that. You said before that you tested the *minified* code.
      But that code differs from the original code. So you cannot know (until it
      is too late) that minifying caused you additional problems.
      >Then we have the issue of semicolon insertion or parenthesizing that
      >needs to be done explicitly in minified code but not in the original
      >code. And probably I have forgotten something else.
      >
      I already covered that (JSLint.) (The semicolons, etc., not whatever you
      forgot.)
      JSLint has problems of its own, as has been demonstrated recently. Suffice
      it to say that even JSLint cannot recognize when parenthesizing or explicit
      semicolon insertion was necessary in the minified version of the analyzed
      code, because that is not only a matter of syntax, but also of semantics.


      PointedEars
      --
      var bugRiddenCrashP ronePieceOfJunk = (
      navigator.userA gent.indexOf('M SIE 5') != -1
      && navigator.userA gent.indexOf('M ac') != -1
      ) // Plone, register_functi on.js:16

      Comment

      • Thomas 'PointedEars' Lahn

        #48
        Re: When to minify?

        Gregor Kofler wrote:
        David Mark meinte:
        >Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
        >think I use it?
        >
        Your penchant for jQuery makes you a prime contender.
        Aren't you confusing David with, uhm, somebody else?


        PointedEars
        --
        Use any version of Microsoft Frontpage to create your site.
        (This won't prevent people from viewing your source, but no one
        will want to steal it.)
        -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

        Comment

        • Gregor Kofler

          #49
          Re: When to minify?

          Thomas 'PointedEars' Lahn meinte:
          Gregor Kofler wrote:
          >David Mark meinte:
          >>Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
          >>think I use it?
          >Your penchant for jQuery makes you a prime contender.
          >
          Aren't you confusing David with, uhm, somebody else?
          Definitely not. Should I have added a ;-) then?

          Gregor

          Comment

          • Thomas 'PointedEars' Lahn

            #50
            Re: When to minify?

            Gregor Kofler wrote:
            Thomas 'PointedEars' Lahn meinte:
            >Gregor Kofler wrote:
            >>David Mark meinte:
            >>>Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
            >>>think I use it?
            >>Your penchant for jQuery makes you a prime contender.
            >Aren't you confusing David with, uhm, somebody else?
            >
            Definitely not. Should I have added a ;-) then?
            Ahh, there:

            | (X) TypeError: this.ironyDetec tor is not a function
            | File: stressed/usenet.js
            | Line: 42


            \\// PointedEars
            --
            Use any version of Microsoft Frontpage to create your site.
            (This won't prevent people from viewing your source, but no one
            will want to steal it.)
            -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

            Comment

            • David Mark

              #51
              Re: When to minify?

              On Nov 20, 5:12 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
              wrote:
              David Mark wrote:
              Thomas 'PointedEars' Lahn wrote:
              David Mark wrote:
              >Thomas 'PointedEars' Lahn wrote:
              >>David Mark wrote:
              >>>Thomas 'PointedEars' Lahn wrote:
              >>>>David Mark wrote:
              >>>>>The answer to "when to minify" is: right before you start
              >>>>>testing the script. [...]
              >>>>Right.  And when the test fails, you go fix the bug ... wait a
              >>>>minute, *you can't*.
              >>>And why on earth not?
              >>Well, let's say testing shows that there's an error in line 42 of
              >>the minified code that you want to fix.  You could attempt to
              >>beautify the minified code again and then compare with the original
              >>non-minified code, but, to begin with, how can you know that even
              >>the lines numbers are the same then?
              >[...]
              >For one, save the original (obviously.)
              When you can't be sure whether the error that occurred in the minified
              code also occurs in the original code in the first place, or the
              problem is the result of the minifying instead, saving the original
              code is not of much help when finding a problem in the minified code.
              >
              Perhaps you are just snake-bit,
              >
              Sorry, I don't follow.
              Perhaps you have had bad luck.
              >
              but I have never found such an error.
              >
              That does not mean anything.
              In the original context it did.
              >
              Before testing, I run the code through JSLint and then the YUI
              "minifier."  Invariably, the code runs exactly as before.  If it ever did
              not, I would find the problem easily enough.  Thanks for your concern
              though.
              >
              >For two, who debugs by line number?
              OK, so how do you suggest to debug a one-liner that is the result of
              the minifying of, say, 500+ LOCs?  And even if you could do that
              *always*, I
              >
              What difference does it make how many lines of code there are (if you are
              not debugging by line number?)
              >
              The debuggers that I have encountered so far work line-based (e.g., set a
              breakpoint on or go to line #n, not statement #n).  There are a few that can
              beautify the code before debugging to make debugging easier (among them
              Venkman), but not all.
              The debuggers I have always used show you the code in question. Some
              better than others. For IE, you need Visual Studio (or InterDev or
              whatever.)
              >
              seriously doubt you can look at one example of p,a,c,k,e,d code junk
              and
              >
              Nobody, but nobody, uses that stupid p,a,c,k,e,r.
              >
              Experience and Google hits disagree.  There are 1'620 Google hits for
              '"p,a,c,k,e, r" javascript", 1'930 for '"p,a,c,k,e, d" javascript'
              as of today.
              And what are those hits? Scripts by nobodies? See how many hits you
              get for userAgent.
              >
              What makes you think I use it?
              >
              I did not imply that.  You deem yourself to be too important.
              >
              tell me at once which identifier in it means which in the original
              code, because obfuscation is one result of this kind of minifying.
              >
              Again, there is no need to track down bugs in the minified code.  If
              there ever were, perhaps I would get a new minifier.
              >
              You cannot know that.  You said before that you tested the *minified* code.
               But that code differs from the original code.  So you cannot know (until it
              is too late) that minifying caused you additional problems.
              >
              Then we have the issue of semicolon insertion or parenthesizing that
              needs to be done explicitly in minified code but not in the original
              code.  And probably I have forgotten something else.
              >
              I already covered that (JSLint.)  (The semicolons, etc., not whateveryou
              forgot.)
              >
              JSLint has problems of its own, as has been demonstrated recently.  Suffice
              Not related to this. (!) Yeah, there is some new superfluous message
              about creating functions in a loop. I've seen it and I actually re-
              factored a loop to shut it up. So what?
              it to say that even JSLint cannot recognize when parenthesizing or explicit
              semicolon insertion was necessary in the minified version of the analyzed
              code, because that is not only a matter of syntax, but also of semantics.
              You seem to have it backwards. Run JSLint first and it will tell you
              where you mistyped. End of story.

              Comment

              Working...