[wp-hackers] Streamlining Includes

Ryan Boren ryan at boren.nu
Mon Mar 3 00:52:45 GMT 2008


Breaking this out from the caching thread...

On Sun, Mar 2, 2008 at 12:03 PM, Eric Marden <wp at xentek.net> wrote:
>  Zend_Framework utilizes this quite a bit so I wouldn't say it is a
>  language thing (php's OO shortcomings aside). But the concept of
>  loading when needed, instead of all at once seems to be a good way to
>  cut back on memory usage. The increase in performance from this, as
>  applied to the current WP, is probably debatable, but maybe worth
>  discussing.

Quite a bit of the time it takes to load the front page is spent
pulling in all of our includes.  A lot of stuff is included just in
case a plugin needs it.  Cutting down on what we include by default
seems a worthy goal.

PHP5 will autoload classes, but that doesn't help us since we neither
require PHP 5 nor use many classes.  Another approach would require
plugins to declare what they need to be loaded and only load what is
asked for.  This would break plugin back-compat, but maybe it's worth
it.  Adding a function like
wp_load_functions($set_of_functions_to_load) and reorganizing some of
our includes could go a long way.  For example, post.php currently
defines all post DB functions.  This includes both functions that read
and functions that insert, update, or delete.  Splitting the
insert/update/delete functions out into edit-post.php and loading that
file only when wp_load_function('edit-post') is called would trim
quite a bit of code from our default includes. Doing this for
taxonomy, links, and other areas could greatly reduce the amount of
code PHP has to load and interpret whenever a blog page is visited.

I'd love to streamline includes for 2.6.  Thoughts?


More information about the wp-hackers mailing list