Vladimir Prelovac just posted some neat tips for plugin developers over on mashable. Here’s one that I really think needs more attention:
#8
WordPress plugins can sometimes be a real resource hog. To make sure your plugin isn’t, you need to localize the usage of resources, by loading them only when you need them.You can use the following example to execute certain code (like declare additional actions and filters) only when WordPress is loading plugins.php page (list of installed plugins in the backend):
$local_pages=array(’plugins.php’); // define pages we want the plugin to be activated on if (in_array($pagenow, $local_pages)) { // do stuff here }Similar to this, you should pay attention to load JavaScript files only when you need them.
All too often I find plugins, like contact forms being loaded on every single page. It’s not that hard to figure out where the user likes to put their contact form, or whatever your plugin does. And while these tips were geared for plugin developers, theme authors should take this advice too as theming becomes more advance and not just an new stylesheet addition.
I’m looking forward to hearing more things like this on the next WP Weekly episode where Jeff interviews him.
You know, with the tips that Vladimir published, I have to wonder between all the plugins I have with certain ones containing their own CSS file, and all of the other stuff just how un-optimized my site really is. One problem I am facing right now is trying to take all of the various CSS files that are loaded by plugins and combined the styles into my themes CSS file so I don’t have to call upon 7-10 separate CSS files. I believe Justin Tadlock is going to write an article explaining how to do this but I believe this helps page loads while also allowing you to edit the style of a plugin without losing your changes when you upgrade it.
Great work your doing, stay focused and you are sure to have a bright future! Nice Free theme also – made our top 100!