Drop Server Resource Consumption to 50% by Tuning WordPress in 10 Minutes

by on August 7th, 2009

fine-tune-wpSince it is vital to give your readers more, provide them information fast, keep your WordPress installation clean and as light as possible in order to make a difference while saving some money form huge Private server cost. Even if you are at some ‘Private Server’ it is always a plus to customize WordPress to load fast and drop some RAM load for which you are going to pay. Here is how I have done something for me to drop my server load to 50% and yet my WordPress is fast and more responsive.

See it by your self. Add a widget in your sidebar and page load time will increase a bit. Keep things that you really need. Keep plugins which you really need and delete all other.

Use Less plugins as possible

Specially be careful about the plugins which affect the single post. e.g. ‘All in One SEO Pack’, ‘Share this’ or ‘Add to Any’ and plugins like these which load whenever a single post is being displayed. Keep such plugins very less and use only essential plugins you need. There was a time I liked ‘Social bookmarking Plugins’ and I had many of those and I used to display more than one plugin at single post. I thought these provide more options for readers. Forget about it. Use one simple easy to use, comparatively small plugin where you are using more than one.

Deactivate less useful plugins

Keep deactivating less important plugins and see whether it takes effect on server load? You have to sacrifice to achieve something. You want speed right? Deactivate all plugins which serve the purpose none other than to make you happy. Get rid of unnecessary and less important plugins. Do it.

Delete deactivated plugins

Do not just deactivate plugins. Delete them and uninstall them. It is a known fact that some plugins even deactivated, their remaining files and processes can cause your blog to behave like a fat lazy guy.

Reduce some PHP Code in Blog Theme

It is totally up to you. There is some code in the blog which never changes or changes once after 2 or 4 months. Why keep that PHP code when you can translate it into HTML. Consider the case of header navigation. Every time any page of post in your blog loads, the navigational PHP code fetches records from DB for menu items and compile the navigation. If you are sure that you are not going to change your nav so often, get rid of that PHP code.

Navigation Change

A sample example is given below.

Usual Header Navigation Code in Blog Theme Header File

<div id="nav">
<ul class="nav">
<li class="<?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php bloginfo('url'); ?>">Home</a></li>
<?php wp_list_pages('title_li='); ?>
</ul>
<div class="clear"></div>
</div>

Changed Sample Navigational Code

<div id="nav">
<ul class="nav">
<li class="<?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com">Home</a></li>
<li class="<?php if (is_page('2')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/aboutpage/">About</a></li>
<li class="<?php if (is_page('3')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/another-page/">Page Name 1</a></li>
<li class="<?php if (is_page('4')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/and-another-page/">Page Name 2</a></li>
<li class="<?php if (is_page('10')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/and-another-page/">Page Name 3</a></li>
<li class="<?php if (is_page('11')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/and-another-page/">Page Name 4</a></li>
<li class="<?php if (is_page('25')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/and-another-page/">Page Name 5</a></li>
<li class="<?php if (is_page('78')) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="http://www.techmynd.com/and-another-page/">Page Name 6</a></li>
</ul>
<div class="clear"></div>
</div>

While in (is_page(‘2’)) 2 is the id number of that page. Go to page section edit a page and you shall know its id there. Use id of pages to identify the navigational control to change the current item CSS and rest all is just a list of pages in plain HTML.

Blog Categories PHP Code

Similarly if you display categories in your blog, you can replace the PHP code from sidebar or remove its widget and put your HTML code containing all the categories. You will have to add category in the navigation though everytime you add a category in admin area.

Keep Homepage as light as possible

Yep. Use less javascript, and use external style and scripts files.

Include Monthly Archives List in Just Homepage

I was looking at it and wondered that why the same archives list displayes all across my blog in header section. If Search engine needs it, fine; it can find it at the home page, right. Why at all other pages.

Locate the following code in header, if you have any:

<?php wp_get_archives('type=monthly&format=link'); ?>

Change it to:

<?php 
if (is_home()) { 
wp_get_archives('type=monthly&format=link'); 
}
?>

That’s it…

Share