JavaScript File Compression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • josh.tucholski@gmail.com

    JavaScript File Compression

    I'm looking for some tools that allow us to implement Javascript Header
    File Compression. I know there are parsers out there that kill all the
    commenting and obliverate the code to make it as small as possible, but
    perhaps if I show our situation we have this may make more sense.

    Our web application has a backbone engine that is downloaded to the
    end-users computer. Currently at a state of 30-40% complete, the main
    engine is over 600 KB and consumes 17,000 lines of code. When this has
    been completed, we expect it to be well near 100,000 lines and are
    quite unsure of the size the file. Is there anything that can compress
    the file to allow for faster downloading to the user only to have it
    uncompressed once they use it on their local machine?

    Thanks.

  • Jim Ley

    #2
    Re: JavaScript File Compression

    On 14 Feb 2006 07:22:47 -0800, josh.tucholski@ gmail.com wrote:
    [color=blue]
    >I'm looking for some tools that allow us to implement Javascript Header
    >File Compression. I know there are parsers out there that kill all the
    >commenting and obliverate the code to make it as small as possible, but
    >perhaps if I show our situation we have this may make more sense.[/color]

    the tool is called gzip, and is handled transparently by the majority
    of web-servers out there, it simply needs enabling.
    [color=blue]
    >Our web application has a backbone engine that is downloaded to the
    >end-users computer. Currently at a state of 30-40% complete, the main
    >engine is over 600 KB and consumes 17,000 lines of code. When this has
    >been completed, we expect it to be well near 100,000 lines and are
    >quite unsure of the size the file.[/color]

    It sounds pretty silly to download 100,000 lines of code in a single
    chunk regardless, why not break the application down into smaller?
    chunks downloaded as and when needed?

    Jim.

    Comment

    • Good Man

      #3
      Re: JavaScript File Compression

      josh.tucholski@ gmail.com wrote in news:1139930567 .842026.50800
      @o13g2000cwo.go oglegroups.com:
      [color=blue]
      > Our web application has a backbone engine that is downloaded to the
      > end-users computer. Currently at a state of 30-40% complete, the main
      > engine is over 600 KB and consumes 17,000 lines of code. When this has
      > been completed, we expect it to be well near 100,000 lines and are
      > quite unsure of the size the file.[/color]

      as noted in a followup, this is close to sheer madness!! surely not all
      pages in your site make use of every class,function and/or variable in your
      script? you should *absolutely* be breaking up that file into several
      '.js' files, and calling only the ones you need as per page requirements.

      an alternative to mod_gzip way of compression [
      http://www.schroepl.net/projekte/mod_gzip/ ] (which is actually very
      excellent unless you are serving up PDF files) is running your scriptS
      through various 'js minimizers' - things that strip out your comments,
      whitespaces and carriage returns. you can use that in your pages, and keep
      the non-minimized one as your development script.

      Comment

      • josh.tucholski@gmail.com

        #4
        Re: JavaScript File Compression

        Sorry for not clarifying this, however the Web Application itself is
        split up into 2-3 thousand lines of code, based on each page module or
        state the user is during the lifetime of the application. However the
        backbone engine that has all of the methods required to communicate
        with the webservice must be kept in one piece. As it approaches 600KB
        this does not seem to cause any problems, especially since the files
        are cached and only grabbed if needed again.

        To get a idea of the extent of this engine, please take a look at
        http://webservice.mynaid.com/ajax/jsdocs/. Thanks.

        Comment

        • Jim Ley

          #5
          Re: JavaScript File Compression

          On 14 Feb 2006 15:25:59 -0800, josh.tucholski@ gmail.com wrote:
          [color=blue]
          >Sorry for not clarifying this, however the Web Application itself is
          >split up into 2-3 thousand lines of code, based on each page module or
          >state the user is during the lifetime of the application. However the
          >backbone engine that has all of the methods required to communicate
          >with the webservice must be kept in one piece.[/color]

          I don't see why? Why do you need to download the code to do a state
          lookup if the user is looking at animal breeds - just have the blocks
          download later.
          [color=blue]
          > As it approaches 600KB
          >this does not seem to cause any problems, especially since the files
          >are cached and only grabbed if needed again.[/color]

          600kb of js takes a long time to compile, there's not just download
          time.

          Jim.

          Comment

          • josh.tucholski@gmail.com

            #6
            Re: JavaScript File Compression

            Jim,

            We could for our application split the files up and call them as
            needed, however this engine is also intended for other 3rd party
            developers to be able to plug into and use as well. Due to the cross
            domain restrictions, they'll need the copy of the engine on their side
            and cant access it from our site. It would be easier to give them just
            one file instead of split it into 60-some odd files (easy for updates
            in the end), however I was just checking if there were any way for the
            compression. I'll look at gzip...thanks for the recommendation.

            Comment

            Working...