[Solar-talk] Squished JS and CSS
Clay Loveless
clay at killersoft.com
Sat Dec 23 12:28:22 PST 2006
On Dec 23, 2006, at 10:36 AM, Rodrigo Moraes wrote:
> Too much for such a simple thing? Any
> thoughts?
Hi Rodrigo,
Too much for a simple thing, I think. :)
Think about it like this: you've got a bunch of content (CSS and JS)
that the browser is going to cache for a long time.
So, the first time the browser gets the file, it'll cache it, period,
unless "cache busting" random strings are tacked onto the URL.
What you're suggesting is a compression routine that happens on
*every request*, despite the fact that the browser already has the
cached compressed version from the first time.
Much less fancy, but much more efficient, method: compress the stuff
with jsmin or one of the other processors first, store the compressed
version as static files in the /public directory, and configure your
web server to handle the gzip compression of you think it's worth the
overhead for the one-time call.
Same result, but doesn't bog down your application or waste cycles on
redundant compression.
You'll notice that there's already a scripts-min directory in the
Solar distro that has compressed versions of the bundled JavaScripts.
I know you're not a protaculous fan, so that may not suit your needs,
but you could be using the -min versions of the JS files from YUI in
a similar fashion.
If you're concerned about ongoing edits and the hassle of keeping a
compressed version of JS and CSS up to date with the development,
uncompressed copies, I would recommend one of two things:
1. A Subversion post-commit hook that would watch for commits to your
JS and CSS files, and when they're updated, export copies, compress
them, and do an automatic commit of the compressed versions.
2. A script on your side that you run before (or during) committing
to your repository that does the compression immediately before
commmitting.
-Clay
--
Killersoft.com
More information about the solar-talk
mailing list