Gilles (Webunity) wrote:
I've build something similar to this; here's how i did it:
on my webserver, there are a bunch of JS and CSS files. During each
page load, i create an array of CSS and JS files, which have to be
included on that page. Currently i store these in session, but that
isn't needed. In the header of the page, i have 2 calls, one to "/
framework/load?css/<scriptname>" and one to "/framework/load?js/</
scriptname>". That script ("load" is a PHP file which reads the array,
generates a hash out of it, checks to see if the files are modified
since the last time they where "build" and if so, recombines all files
and minifies them (in case of JS: Packer, in case of CSS: remove
newlines, comments and tabs). After compiling it writes the generated
file to disk and serves that to the browser. It was a lot of work, but
it allows me to keep all original JS and CSS files on the server (=
greater maintainability) and improves load times drastically.
HTH
-- Gilles
You're saying that is done on each page load. Isn't it better to do that
once, when deploying the files? How long does it take to merge the files?
--Klaus