22 Ways to Optimize WordPress to Load Even Faster
December 5th, 2009Web speed is now becoming a big new topic for webmasters. Especially because Google, the world’s largest search engine now endorses web speed and is starting a movement on it, saying that every website should be compressed and loading faster with all the essential tutorials on the web. Google says browsing should be a good experience and nonetheless, I couldn’t agree more. Web speed overall helps to boost up lost revenue due to bad connectivity and can essentially widen your potential target audience internationally. Simple clean ups or configurations can be the difference from a 6 second page loading time to a 2 second page loading time. Google says they may even consider web speed to be one of their factors in ranking sites in their algorithm (WebProNews). Essentially, this movement is for the better because overall it creates a great browsing atmosphere for your readers and can even lower your web usages, which means, you can be saving money.
You may even have noticed that Mooladays has taken a few actions regarding web speed as well.
22 Ways to Speed Up Your Website
- Compress all CSS & JS into individual documents. Although this may sound like a hard task, it is quite easy with the help of a few plugins. If you are using WordPress, I recommend downloading one of these plugins to combine all your CSS and JS files in one dedicated document for each. PHP Speedy | Web Optimizer. If you don’t use WordPress, using the simple @import url (“myfile.css”); command within the compressed CSS file, always works without much issues.
- Install Firefox with a few helpful extensions. With the help of great developers who made web optimizing tools for Firefox possible for webmasters to track their web performances through a waterfall diagram, enables webmasters the ability to experiment. Such great plugins are YSlow and Google Speed. It is required to have Firebug installed. Once the extensions are installed, you should see a little icon on the lower right of your Firefox browser. From there on out, it should be pretty straight forward.
- Incorporate web caching. Web caching is necessary and SHOULD be incorporated in any website because it can reduce unnecessary web requests by 80%, which means, a faster loading time. If you use WordPress, downloading and keeping one of these plugins updated is essential. WP-Super Cache | W3 Total Cache.
- Remove white space and lines. This is pretty straight forward. All you are really doing is trying to remove all the whitespace or line breaks possible to reduce the file size. Although this can be fairly effective, it is a nightmare to edit. So keeping an offline version WITH the white spaces and line breaks is recommended.
- Compress pictures WP-Smush-it. Wp-Smush-it is a new type of plugin that simply compresses whatever picture type file you upload to your server and automatically compresses it in the background. You get the option to also compress files that were previously uploaded. This plugin was a Yahoo developed plugin made for WordPress users. You can upload the Wp-Smush-it plugin here.
- Gzip CSS and JS files. Gziping and compressing as many possible files as you can, can drastically reduce web size and improve site performance. Yahoo has reported that Gziping your files can reduce up to 70-80% of the original file and still be able to serve the same effects as it was uncompressed. This is a recommended practice by many.
- Optimize database tables. Optimizing the database tables is not the most effective way to optimize a site for better web speed, however, simple repairs can add up. To optimize your database tables, you can either A, do it though a WordPress plugin or B, go to your phpMyAdmin account and manually optimize your database tables. If you choose option A, simply upload the plugin Wp-DBManager into your WordPress blog and follow the installation guide that comes along the plugin. If want to do option B, the actual way, simply log into your phpMyAdmin and then click the database that your blog is using. Check “Check all” tables option, then scroll to the bottom of the page and select “Optimize tables.” After this process is done, your database tables should be fully optimized.
- Install Google Libraries. There are sure various reasons why not many people would want to install Google Libraries. 1 being, if you switch to Google Libraries, you switch out from your local version of jquery.js. This means, if Google’s hosted version of jquery.js ever goes down, which they promised they would never, some data may be lost. Although, no one can say why Google is doing this, one thing is for sure, switching to Google’s hosted version is way faster than the local version of jquery.js. If you do decide to use Google Libraries, it is as simple as installing a plugin and activating it. That’s it. Remember, if you plan on using Google libraries, the file is hosted on Google’s servers, which is why it is faster. I still always keep my local one in tact at all times just to safe even though I know Google will be truthful to their word. Install Google Libraries to your WordPress blog and see the difference in web performance. Experience the quickness of Google’s servers.
- Use a sub-domain to deliver images or JS (CDN). CDN means Content Delivery Network. When you are considering on improving web site speed, you always want your files to be downloaded by users in parallel. This is so by the time other scripts and files are being downloaded, by the time those files are finished, your images and other files are done as well. A good example of CDN being used is Google.
- Turn off post revisions. Every time you save a post, a post revision is written into your database. Overall, the post revisions can really build up and cause some distortion in web performance. Removing this unnecessary functionality, can somewhat improve a site’s performance. To turn off the post revisions option, you must go to your wp-config.php file and add this line of code:
define(‘WP_POST_REVISIONS’, false);Remember before fully configuring anything, to always backup your files to be positive that the procedure will be fail-proof. If you had post revisions on for sometime now, chances are you want to get rid of your previous post revisions to conserve space. To do that, simply run this query through phpMyAdmin and select the appropriate database. Now on the top, you should see a tab that is named SQL. Click it and run this query through it:
DELETE FROM wp_posts WHERE post_type = “revision”;
After you have done this process, ALL your post revisions in the past has been deleted. If this query didn’t work, chances are your database is not named wp_posts, but something else similar. Change wp-posts to reflect the proper database name and then it should work.
- Turn off RSS pings and pingbacks. This will probably be the easiest adjustment you will have to make that will somewhat conserve your web performance. Disabling the option under Discussions, named “
- Remove badly coded or unused plugins. Just removing unused plugins can conserve disk space. Ideally, deleting disabled plugins is a good practice because it ensures there will be no further conflict with other plugins. Badly scripted plugins or unmaintained plugins can be devious for WordPress. When choosing to use a plugin, make sure that that the plugin is up to date and isn’t poorly coded or it may have negative consequences on your web servers.When deleting badly coded or unused plugins, be sure to COMPLETELY delete it from your WP data tables to ensure the most optimized loading speed. More information on how to do that can be found here. Don’t forget to back up your database!
- Minimize the number of HTTP requests. Did you know that most of the time, 80% of a site’s response time is due to too many site components on a single page like Flash, images, stylesheets, scripts, videos, and etc?Reducing the amount of unnecessary HTTP requests, can drastically improve website speed.
- Lower DNS look ups. Before a site’s content is viewable to a reader, the domain name must be looked up. Here is a nice illustration that demonstrates the procedure each time a new external source is present.
Too many DNS look ups can result in a slower loading website, so it is recommended to keep your external imported content from other web servers, to a minimum. Having less than 4 different external domain names is recommended. An example of an external imported content is embedding Youtube videos. The videos are hosted on Youtube’s servers, which contributes to the list of DNS look ups each time a new visitor first visits your website.
- Compress all your content using Apache .htaccess. Compressing your content as much as possible is necessary to squeeze the most performance out of your website. Adding this line of code will thoroughly compress your content as much as possible for better web performance. The .htaccess file can be found in your public_html file. This can be accessible through a FTP program like FileZilla. It is recommended to backup your original .htaccess file and to use a text editor program like notepad to make the changes to ensure it makes the right changes.
# Compress Content
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/x-javascript application/x-httpd-php application/rss+xml application/atom_xml text/javascript - Create expire headers. Adding expire headers is a good way to keep client requests to a minimum. Without them every time the client’s browser requests a file the server has to serve it. Adding expire headers, in this case to the .htaccess file, keeps a cached version of the requested file on the client’s computer in case it is requested again. For example, you have an image gallery. The client clicks on a picture, the picture is served to them, fine. Now when the client clicks the link at the top of your page to return to the main gallery page, ALL those thumbnails of the large images are requested from the server. With this code the client merely retrieves the same images he originally saw again, without the extra server requests. Nice isn’t it?
<FilesMatch "(?i)^.*.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 10 Jun 2050 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch> - Put CSS on top and JS on bottom. It has been proven that putting your CSS on top and putting JavaScript on the bottom, has the best performance. It is as simple as that. This improves parallel downloads from your web host.
- Use short hand CSS. Incorporating short hand CSS when possible, is a efficient way of reducing file size. Although it may not sound like much, overtime, it add ups and can essentially improve your website performance. An example of using short hand CSS is demonstrated below.
- Consider using CSS sprites if possible. Basically what a CSS sprite is one huge image that contains all the general elements of a blog theme. This includes icons, buttons, styles, and more. Using CSS sprites when possible, is a significant way of reducing HTTP requests because every time you pull an image directly from the source, it count as one HTTP request. With a CSS sprite, it only counts as one no matter how many times you use that particular image to pull out images. And to get the proper image you want to display, you use css background-position, to dictate what to show for a particular image. Here is a great free CSS Sprite Generator that you can use easily.
- Clean your HTML code with W3 Validator. Make sure that your HTML validates and is cleanly coded is recommended to ensure the best performance with the HTML code your site contains. Same goes with validating with the W3 CSS markup test. W3 HTML Validator | W3 CSS Validator
- Stop hotlinking. If another person hotlinks an image or anything is being pulling more requests from your web servers, it is using up your site’s resources. Good thing it is really simple to disable people from hotlinking from your web servers. And it involves a little bit of touching up with your .htaccess file. Be sure to back up your original .htaccess file in case anything goes wrong.#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain.com/.*$ [NC]
#RewriteRule .(gif|jpg)$ – [F]
RewriteRule .(gif|jpg)$ http://www.yourdomain.com/stophotlinking.jpg [R,L] - Stop spammers. Just like with hotlinking, if a spammer visits your website, it uses resources. To stop spammers, you can add this simple line of code to your .htaccess file. Be sure to back it up as always. This line of code will further prevent some potential spammers from spamming your site.# Prevent Spammers
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Making use of your sub-domains to parallelize downloads, can really drastically improve your website speed. Creating specific sub-domains for specific files like images, is a great way to organize as well as improve your site performance. As you can see, Mooladays too has incorporated this technique as well to improve parallel downloads for images at images.mooladays.com. A great tutorial on how to import previously submitted images to your sub-domain and configure future uploaded images to be hosted on the sub.domain, can be found here.
div {
margin-top: 5px;
margin-right: 8px;
margin-bottom: 3px;
margin-left: 4px; }When it can be written as…
div { margin: 5px 8px 3px 4px; }Use any one of these free tools to easily check and see if your work is really paying off in a cool waterfall diagram completely free.







The less plug-ins you have, greater loading speed you achieve. So deactivate and delete the plug-ins that are not really necessary for your blog.
Personally, I wouldn’t touch codes that is unnecessary. If the website requires the certain information to pull dynamic information like how the_title() and the_permalink() clearly does, I would just leave it as is because it won’t make any noticeable difference.
Just replace static coding to lessen web requests. Don’t over optimize it or it will do more harm than good when reediting the code.
is it recommended to store repeating functions results in variables?
For example, if I have the_title() or the_permalink() functions appearing more than once in my index.php.
Will it be faster if I type and then echo $title1?
Wonderful tips to minimize the page loading time.. Thanks for the time saving tips..