[wp-hackers] JavaScript concatenation and compression - any documentation?

Andrew Nacin wp at andrewnacin.com
Sat Dec 19 09:04:15 UTC 2009


>
> Eric, I've understood that it works only with core scripts, but what core
> scripts are actually meant here?
>

Consult wp-includes/script-loader.php, specifically wp_default_scripts() and
wp_default_styles().

I thought the talk was about core javascript files. That for example if I
> load javascript files from wordpress installation and not from my plugin
> directory (let's say jquery, farbtastic, jquery ui tabs and some more) I get
> this functionality working (getting those files concatenated that this). Am
> I wrong? Does it work only within wordpress itself?
>

Including the individual files will do just that -- use the individual
files. WordPress does not do any server side processing to JS and CSS files.
To load the concatenated scripts, WordPress has wp-admin/load-scripts.php
and load-styles.php. These files call script-loader.php but do not load up
the entire WordPress environment. This is to prevent loading the WP
environment three times -- once for WP, then for JS and CSS. Thus, you can't
hook into the default scripts that are concatenated by load-scripts or
load-styles. (If you could do that, it would defeat the purpose of offering
a single file the browser could cache, as the scripts that are queued could
potentially change on each page.)


More information about the wp-hackers mailing list