Some self-hosted WordPress sites tend to run slow, especially when you receive tons of heavy traffic every day. This may be a result of the amount of large files your site needs to load or inefficient coding. But there’s nothing worst than a slow site, so here are some quick tips on how to speed up your self-hosted WordPress site. These tips mostly apply to self-hosted WordPress site because if you’re site is hosted on WordPress.com, you’re already being taken care of.
1. Staying up to date with releases
Staying up to date with the latest version of WordPress is critical. In every update, there are usually a lot of performance enhancements. The developers at WordPress don’t release updates just for fun, but because they’ve upgrades or made something about WordPress better.
Same situation with WordPress plugins, stay up to date with the latest versions. It’s as important, and for the same reasons. WordPress plugin developers release new versions because they’ve modified the code in some way to make the plugin better. So keep up with the releases!
2. Disable or delete unused plugins
This is probably one of the biggest issues that causes WordPress sites to slow down. Depending on the plugin, they can have tons of scripts and code. So if you’re not using a plugin disable it and maybe even delete it. Decide which plugins are necessary for your site to run and then do-away with the ones that aren’t needed. It’s as simple as that.
3. Clean up your code
Since your code is what runs your site behind the scenes, optimizing it can do wonders for your load time. Below are some easy ways you clean up your code to load faster.
- Decreasing Whitespace
Whitespace refers to the spaces used in your code. Some coders, like myself, like to use a lot of whitespace (indented tabs, line breaks, etc.) for better readability and organization. But, decreasing whitespace will speed up your site’s load time by shaving off some extra bytes off the total size.
An example of using some whitespace:
.test {
font-family: Georgia, Times, serif;
font-size: 12px;
color: #000000;
}An example of minimized whitespace:
.test {font-family: Georgia, serif; font-size: 12px; color: #000000;} - Using external scripts
Instead of placing tons of code in your header.php file, use external scripts. This allows the browser to cache the script so it won’t have to read it for every other page.
An example of using external scripts:
<script type="text/javascript" src="example.js"></script> - Using shorthand CSS
Using shorthand CSS is great for everyone. It’s great for you, your browser, and your site visitors. It allows for your CSS to be more concise, and it loads faster too!
An example of using
long assregular CSS:.test {margin-top: 7px; margin-right: 1px; margin-bottom: 5px; margin-left: 3px;}An example of using shorthand CSS:
.test {margin: 7px 1px 5px 3px;}
4. Minimize PHP and database queries
And most important of all, cutting down on PHP and database queries. Each time a page on your site loads, if your browser has to execute any PHP queries, it adds to the load time. If you replace the PHP queries with static HTML, every time a page loads, your browser just reads the HTML.
An example of lots of queries & requests:
<title><?php bloginfo(’name’); ?><?php bloginfo(’description’); ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo(’html_type’); ?>; charset=<?php bloginfo(’charset’); ?>” />
<meta name="generator" content="WordPress <?php bloginfo(’version’); ?>” />
<link rel="stylesheet" href="<?php bloginfo(’stylesheet_url’); ?>” type=”text/css” media=”screen” />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo(’rss2_url’); ?>” />
<script type="text/javascript" src="<?php bloginfo(’template_url’); ?>/mootools.js”></script>
An example of minimized queries & requests:
<title>WPCandy - The Best of WordPress</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8” />
<meta name="generator" content="WordPress 2.3” />
<link rel="stylesheet" href="http://wpcandy.com/wp-content/themes/wpcandy/files/style.css” type=”text/css” media=”screen” />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://feeds.feedburner.com/wpcandy” />
<script type="text/javascript" src="http://wpcandy.com/wp-content/themes/wpcandy/files/mootools.js“></script>
By:
January 4, 2008
50 Comments
The last point is particularly helpful. Why I didn’t think about hardcoding certain obvious values before? Thanks for the info, gotta modify header.php
The title tag might need to stay dynamic, though. For single post and so forth.
Anyways, I was expecting to read something about using caching plugin, or even redirecting to a html version during extremely high traffic (like David Airey with one of his posts about the cracking), but then again the title of this post says “simple ways”. So it’s all good.
Cheers!
Great tips. Talking about the first one, the new version of WordPress makes it even easier to have up to date plugins because it tells users when there are new versions of these plugins.
I recommend the plugin WordPress Automatic Upgrade, which makes the updating proccess as simple as pressing one button.
I came up with a question… On my blog I have tons of plugins, but almost all of them are disabled. If I completely delete them from my Plugins folder, would it make any difference in the blog’s speed?
About your example to remove whitespace from CSS code, you could download a version with white space to your computer, then upload a version without any whtiespace to your server.
Then, if you need to change soemthing you have the easy-to-read version on your local computer.
A good online service for formatting and removing whitespace is the CSS Formatter and Optimizer, an online tool.
I guess another important tip is to enable WordPress cache. This is a great feature of the system and can speed up the site.
@ Thássius V. : Disabling alone should be enough to speed up WordPress. Deleting them will save you space, but won’t increase the speed anymore.
Some of these things actually made sense to me!
Especially the queries etc, i didn’t think about that before!
Once I heard about a plugin called WP Super Cache. Somebody said it makes blog loading even faster than WP-Cache does. WPCandy could try it and tell its users the results.
@Bram: Haha, yeah after doing some research, I learned a ton of stuff I hadn’t known before.
@Thássius: I think I’ll do that. I’ll go install it now and see what’s up. I know a friend who uses it for when he receives a lot of traffic and he says it helps a ton.
I love when people write about things they know really well. But I don’t think this article is that case. Try to research, try to measure and you will get know that these advices have almost no influence on performance.
@Kahi: I did do my research and the things I listed here in this post is what I found as a result of my research.
@Michael Castilla: What do you mean by research? I speak about exactly expressable values. DB queries and generation times before all. Do you have some numbers?
I love this, very helpful!
thank you so much for the tips and the great post. Keep it up!
how much does decreasing whitespace in your css really speed things up? are we talking 1% faster? 10% faster?
@Julian Johannesen: Depends on the situations. By decreasing whitespace in the CSS, it makes the file smaller and faster to be loaded by user. Using the CSS Formatter and Optimizer, I could make my CSS file 30% smaller.
Thassius is correct Julian. Decreasing the file size will speed things up. Think about downloading a file, the smaller the file, the better chance you have of getting it right away. Faster someone can download, faster the browser can start decoding and translating the code.
But with modern-day browsers and internet speeds, it probably won’t matter too much. The good benefit of using single line CSS is the ability to go back and be able to read and fix much easier. It is much simpler to find the DIV ID’s as well as being much faster for hand coding out CSS. Single line CSS fan right hurr!
Whats up Kahi’s bum???
I do agree that while this is a spot on article, something new could have been a better option (like the plugin Thássius V. suggested).
In saying that i do like the idea of cutting down the php querries in the header, boy does that not get messy at times??
@Jermayn Parker - it’s all about that listening to advices in this article is wasting of time withou any effect, sure probably except the “disable unused plugins” advice.
By the way, making header static (point 5) does not cause any queries-count decrease, it’s mistake, advicing based on guess.
[...] your WordPress blog running slow? Here’s 4 simple ways to speed up WordPress. Via WPCandy. After reading this post, I realize that I have a lot of cleaning up to [...]
The last point is a huge revelation for me, thanks!
Never quite thought about that before. With regards to the CSS, does the short-hand form work for all browsers?
@Mosey: Haha no problem. And yes I’m pretty sure short-hand CSS works in all browsers, since it’s just leaving out spaces.
@kahi and @Michael
I believe kahi is correct on your last point and you might want to redact if before everyone start taking out that vital dynamic content from their headers. I am pretty sure Wordpress autoloads all those values from the database in one query and then just servers the values from php’s memory.
To test this you could use wordpress’s query number display code which i don’t know off the top of my head. And just check and see if the total amount of queries lessens.
[...] 4 Simple Ways To Speed Up WordPress [...]
Thanks for the helpful tips! Now I’ve gotta implement these…
Great tips. One of the easiest things you could do to speed up the loading of your site is to minimize or eliminate third party services/widgets from being used on your blog. If the 3rd party site is loading slow, it’s going to cause the blogs it’s displaying on to also load slowly. Whenever possible, substitute a thirdparty service/widget with a WordPress plugin. This helps keep things local to your blog.
Thanx a lot. These are very useful. I will try!
Very, very helpful article. I am about 4 months into the whole Wordpress movement and some of these seem obvious. However, I simply did not think about them being issues. Thanks a lot.
Interesting article :
http://aciddrop.com/2008/01/21/boost-your-website-load-time-with-3-lines-of-code/
Please read through the comments for WP related issues and follow-up in new releases of the script ( 0.3.1 at the time of writing )
More thoughts on this issue ( read the comments as well please )
http://paulstamatiou.com/2006/06/22/5-ways-to-speed-up-your-site
[...] 4 Ocak 2008 tarihinde İngilizce olarak wpcandy.com sitesinde Michael Castilla tarafından http://wpcandy.com/4-simple-ways-to-speed-up-wordpress/ adresinde [...]
[...] ini ditulis berdasarkan artikel di situs WPCandy.Com Post a [...]
[...] матеріали: WPCandy, Matt [...]
[...] sizin için avantaj getirecektir. Öncelikle Michael Castilla‘nın ingilizce olarak derlediği yazının Cnkt tarafından yapılan Türkçe çevirisini okuyabilirsiniz. Zorbey.org‘da da bu konuyla [...]
[...] sizin için avantaj getirecektir. Öncelikle Michael Castilla‘nın ingilizce olarak derlediği yazının Cnkt tarafından yapılan Türkçe çevirisini okuyabilirsiniz. Zorbey.org‘da da bu konuyla [...]
[...] sizin için avantaj getirecektir. Öncelikle Michael Castilla‘nın ingilizce olarak derlediği yazının Cnkt tarafından yapılan Türkçe çevirisini okuyabilirsiniz. Zorbey.org‘da da bu konuyla [...]
Some observations:
The thing about removing queries and other PHP stuff: not every one has the same impact. WP actually tries to cache lots of stuff in memory, so that even when you place several functions that’d normally require a trip to the database get pulled from cache instead. That way, instead of the overhead of a database query, you only have the (much smaller, IMO mostly negligible overhead of a PHP function.
There’s a very small overhead in using php functions (in general) vs just putting in some static html. It’s there, but it’s small. You should consider each case separately to see if the speed benefit outweighs the convenience of keeping things dynamic.
Compressing CSS, JS and even HTML are not only interesting from a visitor bandwidth viewpoint (even though there’s still folks that don’t have 20Mbit connections at their disposal, don’t disregard them!), there’s also your own bandwidth to consider, especially if you get the occasional traffic spike. Also, minimizing the amount of stuff that gets called from your page (CSS files, JS files, images, etc): the visitor’s browser will open up a new connection for every single one, slowing things down. Don’t just minimize connections to other sites, keep an eye on connections to your own site as well. One big issue is that lots of WP plugins come with their own versions of prototype.js and the like, while there’s a version included with WP itself — so in the end you’ll end up with three different versions of prototype.js being included on your page. Bah.
Here’s a great tool to test the impact of making your code smaller and less dependant on external stuff.
I like your article, but there’s so much more to discover when it comes to getting your sites smaller and faster. Initially, that’s all I wanted to say. Sorry about going on and on. =]
I heard that one plugin in particular could really slow down your blog is Text Control ( http://dev.wp-plugins.org/file/text-control/trunk/text-control.zip?format=raw)
Can anyone verify that?
[...] 4 Simple ways to Speed up Wordpress (Source: WP [...]
[...] 4 Simple ways to Speed up Wordpress (Source: WP [...]
[...] 4 Simple ways to Speed up Wordpress (Source: WP [...]
[...] 4 Simple ways to Speed up Wordpress (Source: WP [...]
[...] 4 Simple Way To Speed Wordpress [...]
[...] (или справочный лист по WordPress) (см. также advanced help sheet ). Four Simple Ways to Speed Up WordPress (или Четыре простых способа ускорить WordPress) также [...]
[...] Оригинал статьи: 4 Simple Ways To Speed Up WordPress [...]
[...] with static HTML, every time a page loads, your browser just reads the HTML. An example from WP Candy: With PHP requests: <title><?php bloginfo(’name’); ?><?php [...]
[...] матеріали: WPCandy, Matt [...]
[...] Daily Blog Posting To Your WordPress Blog. 124. Huge Compilation of WordPress Code. 125. 4 Simple ways to Speed up Wordpress. 126. WordPress Date Button. (Source: WP Designer. 127. Wicked WordPress Archives in One Easy Step! [...]
Going with #2, also clear out database tables created by plugins.
Instead of writing CSS without any whitespace (which makes it unreadable, a better idea is to write CSS in the normal way and compress it with CSSClean (don’t be too aggressive on compression lest it strips out necessary rules). [oh wait, I just noticed it has been told by someone else. Oh well!]
The PHP engine is infinitely faster than MySQL, so the only thing of concern is database queries. However, in case of traffic spike, PHP can be a bottleneck too.
[...] Diantara posting terbaiknya adalah WordPress Help Sheet (lihat juga advanced help sheet). Four Simple Ways to Speed Up WordPress merupakan informasi yang sangat berguna untuk Anda pengguna WordPress yang hosting [...]
[...] 4 Simple ways to speed up WordPress [...]
Cool info. Thanks for sharing.