11 Ways to Speed Up WordPress

Discussion in 'Blogging' started by HoNeYBiRD, Jul 20, 2010.

  1. HoNeYBiRD

    HoNeYBiRD Jr. VIP Jr. VIP

    May 1, 2009
    Likes Received:
    Geographer, Tourism Manager
    11 Ways to Speed Up WordPress

    1. Caching

    Utilize WordPress Object Cache
    By inserting this simple code into your wp-config.php file, you can set WordPress to begin caching database queries rather than initiating new server requests on each load. You don't have to understand why this works, it just will.

    1. // Enable the WordPress Object Cache:
    2. define(ENABLE_CACHE, true);
    Read more on this topic:

    By reducing the number of queries, you'll both increase the speed of your site, and reduce the server resources that are consumed each time you receive a visitor. As a result, you'll find that it will make your web host much happier in the event of a huge traffic spike.
    Utilize a caching plugin
    The main plugin that meets this need is the WP Super Cache, which does exactly what it says. It caches posts and stores them as files on the server so that repeated requests are dealt with faster and with fewer resources. The plugin will automatically update as comments are added so the dynamic nature of the blog isn't lost.
    Another option, which is used right here on Mashable, is W3 Total Cache. It's a plugin that promises 10 times the speed of your site without it.

    2. Choose the Right Host

    There are several web hosts that are optimized to run WordPress. And while WordPress is not that picky, it does have a set of ideal server settings. Most web hosts meet the basic requirements, but you can find more information about what's necessary here.
    Choosing the right host means more that just buying storage space. Many discount hosts will try to fool you with promises of massive server space at a cheap price because they know you will likely never use the promised enormous allotment. You should really be aware of:

    • Bandwidth
    • Processor speed/type
    • Databases allowed
    • Domains allowed
    • Which versions of PHP, MySQL, etc. are installed
    Look for hosts that have more of a commitment to WordPress as a CMS and blogging platform and not just a mention at the bottom of their features list. Another solid resource is the WordPress hosting page.
    Also, though most shared hosts will likely be running Apache, keep in mind that WordPress can also run on NGINX, which can increase your server's speed by changing the structure of the server requests. NGINX powers massive websites like Hulu, SourceForge and WordPress itself.
    If these big boys choose NGINX, you know it delivers.

    3. Prune Your Plugins

    Take a look at your plugin list and remove the inactive ones. Then remove the any actives ones that you don't actually use; they are likely to place a strain on your serve resources because WordPress loads all plugins when a page loads.
    Make sure you're always running the latest stable release of both WordPress and your plugins. Many older WordPress plugins are not efficient and will weigh your blog down.
    WordPress 3.0 comes with a revamped plugin update feature, allowing you to update plugins faster, smoother and easier. It also offers a bulk update feature that is completely new to WordPress, so there's no excuse for letting your plugin versions expire.

    4. Choose the Right Theme

    Themes can make or break a WordPress installation. Go for something stylish but simple. It's important to understand that fewer images will equals less loading time, which means a speedier site. Choose themes with the fewest possible images and a CSS-based design. Themes with tables, frames and static HTML will be slower than those based on the latest technologies. You might want to choose a minimalist theme and modify it to suit your needs.
    There are many resources for minimalist themes, including this one Six Revisions and this one at Tripwire Magazine. Don't just take the theme's simplicity as a sign of load speed, though; check the actual speed using something like YSlow or Pingdom's Page Test.

    5. Compress Images

    While a clean page means speed, you have to balance that with the fact that strong supporting images are key to a successful blog. But there is no reason to sacrifice speed for quality. By ensuring your images are appropriately formatted and compressed, you can help increase your blog's speed.
    The easiest way to remember formatting is like this:
    Images that use only a few colors should be saved as .GIF or .PNG files, and images that use a full spectrum of colors (like true photographs) should be saved as .JPG files. If you use photo editing software, like Photoshop, you can "save for the web," which will find the best format to save, while still maintaining quality.
    Next you should resize images to the smallest possible size to get the job done. When doing so, the color format should be RGB, as indexed images don't scale well.
    When saving, set the total color amount to the smallest value possible without sacrificing quality. A combination of these steps will greatly decrease your image size and therefore your server response time. You should play around a bit to find the right format and experiment when uploading to determine which settings produce the smallest, high-quality image.

    6. Compress Your Code

    Stylesheets are easy to compress, just use your favorite text editor to delete comments and unnecessary spaces and line breaks. Although you won't see a drastic difference unless your style sheets involve tens of thousands of lines.
    Compressing JavaScript isn't as simple, but it is still relatively easy. There are a number of tools available, such as this one, which is free, that will compress your JavaScript code for you. Better yet, don't rely on much JavaScript at all if you can help it. If your site has lots of interactivity, moving parts and fancy features, there is a good chance it is running a lot of JavaScript and that could slow things down.
    Additionally, you may use the Yahoo! YUI compressor tool or the Google equivalent compression tool. Either one will tighten up your code to make it run more efficiently. Coder Journal has a nice comparison of the various tools for JavaScript compression.
    Use CSS Sprites
    CSS Sprites allow designers to create interactive images, or multiple images using CSS instead of bulky and slow loading JavaScript. Sprites are an advanced technique, but here is a great tutorial at A List Apart. There is even a plugin developed specifically for WordPress that helps with the use of CSS Sprites.

    7. Keep It Local

    Don't rely on other people's servers to be fast, so minimize any widgets, badges or applications that run off other locations. If possible, try to self-host all images and code, such as your analytics. That said, if you're posting videos use a service that is built for such a load, like YouTube or Vimeo.
    But if you are expecting (or receiving) lots of traffic, you may want to look at paying for a dedicated server and not trying to host all your projects in that one place alone. A lot of people don't realize that the geographical distance from a server actually matters. If the vast majority of your traffic comes from a specific country or region, consider locating your hosting close by.

    8. Reduce PHP and HTTP Calls

    Websites were once built statically, meaning that each page was hand-coded and built from the bottom up. Now, most websites are generated dynamically each time a visitor loads the page, which allows for each experience to be custom designed for each person, making for a richer browsing experience.
    In order to accomplish this, many websites use PHP, a scripting language that allows you to reference remote content based on criteria set by the developer. For example, a site might use PHP to determine that this is a first-time visit, and the site may then use this information to generate a welcome message.
    Each time one of these PHP "calls" is made, a request is made to the server hosting the website, which takes time (usually milliseconds). This time is called "latency," and some websites have thousands of calls each time the site is loaded, which can translate to millions per day depending on traffic.
    Wherever possible, scan your site for PHP requests and replace with static HTML. By doing this, the browser will simply read the HTML as opposed to asking the server what it should display. Here is an example of a slow and fast way to produce the same result:

    <?php bloginfo(name); ?><?php bloginfo(description); ?>
    <title>Mashable - The Social Media Guide</title>

    There's more you can do to minimize PHP calls. This tutorial will help you cut down the PHP calls that occur in the typical WordPress header. You can also reduce PHP calls by eliminating any logging that might be happening; some advanced plugins offer an option to track plugin activity with a log, which can significantly slow down your WordPress site.

    9. Keep Your Code Clean

    You can validate your code using the W3C Validator. It might seem snobby to have "standards" on the web, but the truth is, there are standards for a reason. If everyone met the standards, browsers would always know how to display the information they're given. Use the tool at W3C to validate your code and fix any errors. This can be a painstakingly long process but it's well worth the end result.
    Coding errors will slow your load time, especially if images that are referenced but don't exist. Use a bug tool like Firebug to identify coding errors and fix them.

    10. Database optimization

    Using a database administration interface like phpMyAdmin, you can select all tables and click "Repair" and "Optimize," and scan for outdated tables that weren't deleted when you removed old plugins.
    This plugin will take care of the database optimization while letting you stay out of the database itself. While this other plugin offers automatic optimization which may be better for the hands-off blog author.

    11. Adjust Your WordPress Settings

    Go easy on the front page
    There's no reason to show 100 posts on the front page, and really, you don't even need to display the full post content on the front page. You can adjust this setting in the WordPress Dashboard under the Settings > Reading panel.
    Turn off inter-blog communication
    By default, WordPress interacts with other blogs that are equipped with pingbacks and trackbacks. Every time another blog mentions you, it notifies your site, which in turn updates data on the post. Turning this off will not destroy links to your site, just the setting that generates a lot of work for your site. For more detail, read this explanation of WordPress Pingbacks, Trackbacks and Linkbacks.

    I assume i don't have to say how important the speed of your websites is: speed is a very important factor when Google ranks your sites, plus nobody likes browsing a slow/crashing website!

    I've just come by this article, i copy-pasted almost the whole, but you can read the original here:
    Kudos to the author of course!
    • Thanks Thanks x 8
    Last edited: Jul 20, 2010
  2. mikie46

    mikie46 Jr. VIP Jr. VIP

    Aug 6, 2008
    Likes Received:
    And the most important of all points.

    Run your WP blogs on Lighttpd not Apache. My sites load in seconds no matter how many plugins or any of the above is violated. Lighttpd, the only way to go!
    • Thanks Thanks x 2
  3. SugarBooty

    SugarBooty Registered Member

    May 31, 2010
    Likes Received:
    Honestly this information is going to help me a lot. Thank you. :)
  4. AllInOneSEOServices*

    AllInOneSEOServices* BANNED BANNED

    Apr 25, 2010
    Likes Received:
    Wow.. Great info.. i am going to do this to my wp sites right now..
  5. redim

    redim Registered Member

    May 29, 2009
    Likes Received:
    Hi all:

    here is my contribution:

    I installed these plugins and observed some load speed improvements:

    - footer-javascript

    - wp-css

    I am reluctant to install caching plugins because some of the content on my sites is dynamic.

    • Thanks Thanks x 1
  6. Tanksapka

    Tanksapka Registered Member

    May 7, 2010
    Likes Received:
    or you can write your own blog..and it will be 20 times faster
  7. pspparty

    pspparty Registered Member

    Jul 21, 2008
    Likes Received:
    Never heard of Lighttpd ( yeah im a noob i guess ). Im assuming its offered by certain webhosts? Got any recomendaitons?
  8. xSubZer0x

    xSubZer0x Junior Member

    Apr 3, 2009
    Likes Received:
    i agree i'm running all my site's on lighttpd its faster and more secure then apache.
  9. webbie

    webbie Registered Member

    Mar 25, 2008
    Likes Received:
    I appreciate the posts on this thread because WP has seriously been hanging on a never-ending note. But I had already done some of what the OP stated, but will do the others. Hope it works out for me. Thanks you all.
  10. fencersbeatngu

    fencersbeatngu Registered Member

    Nov 19, 2009
    Likes Received:
  11. pucky

    pucky Junior Member

    May 8, 2010
    Likes Received:
    Search for LIGHTTPD HOSTING in google and you'll get hits. No idea how reliable they are. I own my own boxes and collocate them in L.A. I run nothing but lighttpd on 7 servers and i would never host on anything else since i switched. Its highly technical since you have to setup everything manually but in the end its worth it.
  12. voodoo1

    voodoo1 Registered Member

    May 2, 2010
    Likes Received:
    Interesting...run another plugin to speed up WPblog!