This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WP Autoload


Most themes have a single stylesheet, a few JavaScript files, and all the PHP in functions.php. WP Autoload makes it trivial for theme developers to split up CSS, JS, and PHP per template, simplifying development and maintenance. It also makes it much easier to write per-template unit tests.


  1. Upload the plugin to your plugins directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Check the settings on the configuration page (Settings -> WP Autoload)


How do I use this in my theme?

WP Autoload looks for files in the same way WordPress looks for templates, but it also loads ‘parent’ files. Say your theme looks like this:

themes/   foobar/     css/       archive.css       page.css       page-bar.css     inc/       page.php       page-bar.php     js/       archive.js       page.js       page-bar.js 

For an archive page, WP Autoload will load:

  • css/archive.css
  • js/archive.js

No surprises there.

For a normal page, WP Autoload will load:

  • css/page.css
  • inc/page.php
  • js/page.js

WP Autoload will then try to create a new WP_Autoload_page object. The class must extend WP_Autoload_Template, e.g.:

class WP_Autoload_page extends WP_Autoload_Template {   ... } 

For a page with a slug of bar, WP Autoload will load:

  • page.css and page-bar.css, with page.css as a dependency of page-bar.css
  • page.php and page-bar.php, in that order
  • page.js and page-bar.js, with page.js as a dependency of page-bar.js

WP Autoload will then try to create a new WP_Autoload_page_bar object; because page.php is loaded first you can do this:

class WP_Autoload_page_bar extends WP_Autoload_page {   ... } 

What about performance?

For templates where there is no specific stylesheet or script file the performance implications of WP Autoload are negligible. For templates with both a specific stylesheet and script file WP Autoload will add two requests to the overall page load sequence. Typically these extra requests have no significant impact on page load time because they are offset by the reduced size of the common stylesheet.

Contributors & Developers

“WP Autoload” is open source software. The following people have contributed to this plugin.

Translate “WP Autoload” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



  • Support for hierarchical post types.


  • Bugfix: fix debug warning with E_ALL.


  • Bugfix: fix loading base classes.


  • Bugfix: remove debug code.


  • Support for child themes.


  • Per-template classes.
  • Better sidebar handling.


  • Dependencies configuration bug fix.


  • Improved template part list filtering.


  • Add enqueue_script() method to allow scripts to be enqueued after wp_head().


  • Tag fix.


  • Handle single dependencies better.


  • Fix minor PHP warning.


  • Initial release.