Edit your theme and speed it up so your blog loads fast


Trimming WordPress on the Theme Side

All sites should be as fast-loading as possible, and that applies to WordPress-powered sites as well. You can do quite a lot on the theme side of things, but the question is how much you really want to do. If you take it to the extremes, you’ll end up with one-line files that will be completely impossible to edit, which means you’ll need a non-optimized workfile that you later optimize. This usually applies to stylesheets, which can be smashed together quite a lot, and hence you’ll save a few bytes, but it also means that you won’t be able to scan them easily when looking for something. So with that in mind, what can you do to speed up your theme?

Clean out unnecessary code. Most themes would do well with a going-over or two after they appear to be finished.Minimize PHP usage. Direct links to images in your theme directory, usually called with bloginfo('template_directory'), will save you several PHP calls. There are a lot of those in most themes, as there is automatic output of the site’s name and things like that. If you expect large amounts of traffic, hardcode that into the theme instead.

Beware of plugin overload. Plugins are great, but sometimes they aren’t all that well designed. At the very least, they represent one or several more PHP queries and possibly database processing. You should consider each and every one of them carefully.

Outside services. This is not strictly in your theme, but outside services such as chat widgets or Twitter badges take time to load and will impact the performance of the site in the eyes of your visitors.

Accelerate and cache PHP. Your hosting solution of choice may offer PHP accelerators and caching for often-called functionality. Talk to your hosting provider for options, and then make sure that they are compatible with WordPress; all may not be.

WordPress caching. There are caching plugins for WordPress that store static files rather than serving data from the database all the time. This can actually speed up a site, so it may be worth considering.Tighten the files. You can Google your way to both HTML and CSS compressors, which tighten your files but make them a whole lot harder to read. Be sure to check the output to ensure that the compressors’ scripts haven’t added something malicious. You can never be too sure.

In the end, tightening a WordPress theme is more or less the same as tightening any site. Good and tight code, preferably valid, will load faster than clunky and bloated code, so get it right from the start. And if you’re doing everything right but your WordPress site keeps chugging slowly, then maybe you’ve outgrown your host. After all, when all the PHP calls are minimized, the code is tight and valid, and you’ve got your accelerators and caching, then there’s just not much more that you can do other than crank up the voltage to power your beast.

Some Words on Themes

The themes are not only the look and feel of a site these days, they are also simple plugins. You use themes to get everything to display where you want, and to break the normal flow of posts provided by the loop. Thanks to the template and conditional tags, there are a lot of things you can achieve, and by adding extra functionality in functions.php, by using action hooks, and by being crafty overall, you can build just about anything.

As I’ve hinted at in this article, cramming functions.php full isn’t always such a great idea. A lot of things you do in that file can just as well be done by a plugin, and while that is unnecessary or even redundant at times, sometimes it truly is the best decision. After all, the whole idea with various skinning concepts in publishing systems is to separate as much design from the code as possible. When it comes to WordPress themes, it means that you’ll have to break that rule a bit if you want to do crafty things.A lot of those things can be plugins rather than code in the themes, which would fit better with the whole dividing design and code concept.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.

Note: This article was sent to us by: Eliott Anister at 05212010

Related Articles

1. How to do lifestreaming with WordPress
Lifestreaming with WordPress Lifestreaming is a term commonly used to describe the mashing up of everything you do online. A bit presumptuous, perhaps, to assum...

2. Social Web Submit Buttons plugin Worspress
Social Web Submit Buttons The social Web is certainly a big consideration when working with editorial content today. While search engines can trickle in visitor...

3. Wordpress Hosted Comment Solutions
Pimping the Comments With the addition of threaded comments in the WordPress core, and the excellent CSS styling options that are now available, as well as the ...

4. How to Backing Up database for Wordpress
Backing Up Anyone who has lost data in a hard drive crash or similar knows the importance of backing up, and it goes without saying that this applies to your on...

5. What you need to know about the Wordpress database
Hacking the Database Most of the time you needn’t worry about the database; WordPress will do that for you. There are database changes between versions so...

6. Switch hosts with wordpress when export and import do not work
WordPress and Switching Hosts There are several ways of moving to a new server. My preferred one is using the Export/Import functionality found under Tools in W...

7. Do not share your MySQL user with any other system
Server Stuff The MySQL user for your WordPress database, which incidentally shouldn’t be shared with any other system, doesn’t actually need all wri...

8. What is WordPress core and how to use template tags
About the WordPress Core Any good CMS will keep its core files apart so that you don’t ruin the code that makes the system work, and WordPress is no excep...

9. Creating multiple loops might harm your WordPress blog
Alternatives to the Loop You may be tempted to create multiple loops or advanced loop queries in your theme’s template files when you’ve figured out...

10. How to do everything with your WordPress theme
WordPress Themes If you want to do more advanced stuff with WordPress, you need to understand theme essentials. Naturally, you can just start hacking the defa...