@Erik:  (Damn this Groups post delay...)  Minify does exactly that,
but with CSS too.  Minifying, caching, and single-request serving.

On Aug 15, 2:32 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
> I cache the packed versions. Actually, I concatenate all of the scripts that
> I need for a page, minify them (used to use packer, now I use YUImin), and
> then cache that, all on the fly. So I have one script tag like:
>
> <script type="text/javascript" src="/myscriptmerger/dimensions.js,sort.js,
> myscript.js"></script>
>
> On the first request, I merge the three scripts, minify them, write them out
> to a cache file, and store the cache file path with the script names. Next
> time I get these same scripts in this order, I serve out the cached version.
> This has quite a few benefits: it allows me to have whatever scripts I need
> on a given page, it keeps my scripts readable on the server while still
> compressing them for the client, and it reduces the number of HTTP requests
> necessary to load all of the scripts.
>
> The only real downside is you may lose a little performance from things not
> caching as much as they would if they were in separate files, so I don't
> serve up jquery.js/interface.js/ext.js this way hoping that the browser will
> cache them.
>
> --Erik
>
> On 8/15/07, Ganeshji Marwaha <[EMAIL PROTECTED]> wrote:
>
>
>
> > Very cool... I will start using this technique right away...
>
> > But my only concern is, since this technique compresses the file everytime
> > it is requested, isn't it an overkill on the server's CPU?
>
> > -GTG
>
> > On 8/15/07, Stephan Beal <[EMAIL PROTECTED]> wrote:
>
> > > Hi, all!
>
> > > i'm working on re-designing the web site for my mother's company,
> > > which was horribly neglected/abused by the previous webmaster, and i
> > > came across an interesting problem...
>
> > > A part of the refactoring is to use jQuery for parts of the site.
> > > However, since all of the pages use the same site layout template
> > > (which includes the headers/script tags) yet most of the site won't
> > > actually use the JS features, i wanted to make the jQ download as tiny
> > > as possible.
>
> > > Unfortunately, i don't have admin rights on my server so i cannot
> > > activate mod_gzip/mod_deflate to gzip the stuff on the fly. But here's
> > > an easy workaround...
>
> > > Create a PHP file called jquery.php:
>
> > > <?php
> > >   ob_start( 'ob_gzhandler' );
> > >   echo join('',file('jquery-1.1.3.1.pack.js'));
> > >   ob_end_flush();
> > > ?>
>
> > > Now, in the main site layout template i have:
>
> > > <script type='text/javascript' src='/include/js/jquery.php'></script>
>
> > > Firebug confirms that the jQ transfer is then 12k, which is tolerable
> > > for my purposes.
>
> > > It would be only a tiny amount of extra work to integrate the PHP port
> > > of Dean Edwards' packer, such that the packing is done each time
> > > jquery.php is called, but that seems like overkill to me.
>
> > > This approach could just as easily be used to combine all required JS
> > > scripts on the fly (just be sure to insert a ';' after each one to
> > > accommodate scripts which don't have them), then gzip them, to help
> > > reduce the overall download overhead.

Reply via email to