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

Davit Barbakadze jayarjo at gmail.com
Sat Dec 19 11:06:03 UTC 2009

I never looked into admin source until now. Hm...

Why does it load scripts that way? I never understood why this problem
with external javascript files, until I really saw how wordpress
actually does concatenation

What was the idea behind it? I mean there they are all the scripts on
the server side queued in the scripts queue and sorted by dependences.
Can't we do concatentation right there? Before outputing those scripts
to the browser? Why it is done after? Otherwise of course there will
arise a problem of multiple inclusion of the wordpress core (as well
as other weird things).


On Sat, Dec 19, 2009 at 1:04 PM, Andrew Nacin <wp at andrewnacin.com> wrote:
>> 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.)
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Davit Barbakadze

More information about the wp-hackers mailing list