[wp-hackers] Packing JavaScript
Otto
otto at ottodestruct.com
Tue Sep 18 17:54:31 GMT 2007
On 9/18/07, Kevin Newman <CaptainN2003 at yahoo.com> wrote:
> Since WordPress has a queue script function, WordPress knows about all
> the scripts that would be needed before they are output to the header
> (assumption, I didn't look into the code yet). So why not glue all the
> queued scripts together in a single file and then gzip them in one shot.
> This would reduce the number of connections to the server, as well as
> reduce the file size of the gzipped scripts.
>
> And since it's going through php, we could add other performance
> enhancing features, such as far future expires headers (we could
> construct a url that contains information about the included files, and
> their versions so that updates could be retrieved by clients, if things
> need to change).
+1 to using a wrapper script to gzip the js's.
+1 to add better header control to that, to increase cache time to
longer periods.
-1 to concatenating all the scripts together. This eliminates the
benefit of caching and also makes the variable header code less
effective at caching of the normal pages, since script enqueues may be
variable. Also it introduces problems with how to make an effective
naming scheme for the concat'ed js's.
> TinyMCE already has a similar feature (it packs it's many separate js
> files into one, then gzips it using php).
TinyMCE is a special case. It does that because it pretty much has to,
being made of dozens and dozens of JS files. And seeing that JS
doesn't have a good way to include other JS files from JS files, it
would be incumbent upon the html author to include all those script
files manually, which would be a nightmarish pain in the ass.
More information about the wp-hackers
mailing list