Support » Requests and Feedback » Use spl_autoload to load classes

  • One beef I have with WordPress is how much resource it uses up.

    The average script execution can eat up to 15MB in the front end and a lot more in the admin section.

    The reason for this is that Worpdress includes a ton of code at each run that it just doesn’t use. For example, it loads ALL the http protocol wrapper classes every time wp-cron is run, when only one of them is actually used. It loads, and does tons of useless processing, all built in sidebar widgets whether any of them are used or not. I’m guessing 50% of the memory usage is just clutter.

    My request is:

    Since WordPress now requires PHP5 to run so why not use spl_autoload to load what’s needed only when it’s needed? I’ve looked at the roadmap on the wordpress trac and there doesn’t seem to be plans to implement an autoloading method for now.

    I’ve done some tests by splitting the WP_HTTP_* classes into individual files and making a simple autoloading function and the average memory usage dropped 600KB from just that!

    I think it’s kind of important since wordpress has become so much more complex. and will probably put on more weight as it evolves.

    It would require some work though because class naming conventions is a bit inconsistent within WP_* classes. Most third party libraries are edited to be used by wordpress anyway so their names could be standardised too.

    Eventually all functions within wordpress past a very small and efficient core could be autoloaded. Like the massive number of template functions.

    I was also wondering if it’s okay to start a fork of wordpress geared towards performance, implementing autoloading. In case it can’t be done in the near future releases.

  • The topic ‘Use spl_autoload to load classes’ is closed to new replies.