Speed Up Wordpress By Reducing Dynamic PHP And HTTP Calls
April 6, 2009
You can sped up the loading of your Wordpress pages if you reduce the number of dynamic PHP and http calls. In plain English (which I prefer) it means look for code starting with “<?php" in your header.php document and replace as many of them as possible with their static URL equivalent.
For me the easiest way to do that is to look at the source code of my index page (where all the values are already called) and just copy and paste what I choose to change from there into header.php.
THIS IS THE ORIGINAL CODE IN MY HEADER.PHP (this does not differ much from theme to theme):
************************************************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta name="distribution" content="global" />
<meta name="robots" content="follow, all" />
<meta name="language" content="en, sv" />
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
<!-- leave this for stats please -->
<link rel="Shortcut Icon" href="<?php echo get_settings('home'); ?>/wp-content/themes/eyecandy/images/favicon.ico" type="image/x-icon" /><link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php wp_head(); ?>
<style type="text/css" media="screen">
<!-- @import url( <?php bloginfo('stylesheet_url'); ?> ); -->
</style>
</head>
************************************************
THESE ARE THE CHANGES I MADE:
from
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
to:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
from:
<link rel="Shortcut Icon" href="<?php echo get_settings('home'); ?>/wp-content/themes/eyecandy/images/favicon.ico" type="image/x-icon" /><link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
to:
<link rel="Shortcut Icon" href="http://YOURDOMAIN.COM/favicon.ico" type="image/x-icon" /><link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://YOURDOMAIN.COM/feed/" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://YOURDOMAIN.COM/feed/" />
<link rel="alternate" type="text/xml" title="RSS .92" href="http://YOURDOMAIN.COM/feed/rss/" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://YOURDOMAIN.COM/feed/atom/" />
<link rel="pingback" href="http://YOURDOMAIN.COM/xmlrpc.php" />
Note: I always keep my favicon.ico in my root directory (optional).
from:
<style type="text/css" media="screen">
<!-- @import url( <?php bloginfo('stylesheet_url'); ?> ); -->
</style>
to:
<style type="text/css" media="screen">
<!-- @import url( http://YOURDOMAIN.COM/wp-content/themes/YOURTHEMEFOLDER/style.css ); -->
</style>
Also I deleted these lines of unnecessary code I do not need (some people may want to keep them):
<meta name="distribution" content="global" />
<meta name="robots" content="follow, all" />
<meta name="language" content="en, sv" />
<?php wp_get_archives('type=monthly&format=link'); ?>
I did not mention changing the <title> tag in this post because that deserves its own separate article because there are a few different schools of thought on how it should be optimized.
Become a Woo Wordpress Theme Club Member
to Access The Best Premium Themes!


