Post image for How to Speed Up Your Website Part-II

How to Speed Up Your Website Part-II

by Bobby Jay

Part-1 of article was based on server side optimization. Now in Part-2 of this  series we are focusing on WordPress itself for optimization and speeding it up.

Free up Your Database:-

I love WordPress because it is very rich in features and extremely customizable. Flexibility is endless. Opps, I am de-tracked. Let’s get back to our work.

WordPress has a feature called revision. After every 60seconds, WordPress saves a copy of our non-published post which is called a “Revision”. After publishing, revisions exist in the database and populates the database with this useless data.  Use this SQL query to delete all revisions and free-up your database.

DELETE FROM wp_posts WHERE post_type = "revision";

Static Page Vs Dynamic Page:-

WordPress creates dynamic pages by default and uses MySQL and PHP as its backend. MySQL and PHP both consume system resources. Just imagine if you have 5000+ clicks then each time your landing page is dynamically generated. A number of SQL queries are executed. Try to change your landing page from dynamic to static. This is very easy in WordPress.

Minimal Use of Plugins:-

Only use essential plugins for WordPress, based on your needs, and avoid self hosted stat programs or plugins. We have a variety of plugins that generate stats for us. They increase SQL queries and use PHP. Below we have  some code for showing the number of queries  executed when a visitor visits your website. Only a logged in user will see the query result at the bottom of the page.

Now look at the number of queries that are executed and the time consumed in execution. Disable all your plugins and observe the number of queries executed and then activate one by one the most needed plugins and observe the number of queries. You will soon find a plugin that executes a large number of SQL  queries, avoid such plugins or find an alternate to them.

Use as Few HTTP Requests as Possible:-

For successful website, some attractive graphics is key to success. No one will like a dull website with text only. Modern websites use images, JavaScripts, Flash and movie clips to attract users. On each request, the web server has to establish a connection, send HTTP requests several times. Hence the result is slow loading of pages. Combination of text and graphics is wise strategy.

Use Relative Paths Instead of Absolute Paths:-

Though this part can be part of above tip but we are treating it under separate heading (more and more content J). Using absolute path for images, Flash, JavaScript and movie clips surely increases http request. So use relative path instead of absolute path to reduce the HTTP request.

An example of absolute path might be;

Use relative path to reduce HTTP request. An example of calling same image file by using relative path is;

Use Content Delivery Network:-

Modern internet is full of blessings. For images, flash, and movie clips use the content delivery network. Flicker and similar websites provide the services to host the images. YouTube and related websites provide faster web server for hosting the movie clips. All of them are for our facilitation. Take maximum benefit from them and save your expensive disk space.

Reduce the Number of DNS Lookups:-

We will use 2D approach to analyse this tip. Every time we use absolute path, browser performs DNS lookup and find its IP. So use relative path to eliminate this delay.

If you are using some content delivery network, use their IP instead of their address for using multimedia contents in your website. This will drop the wait for DNS lookup.

Use Caching for Faster Page Loading:-

WordPress has an excellent plugin called “wpj Super Cache.” Use of this plugin is highly recommended.

Second approach to use caching technique is to add an “Expires” Header. By using this technique, after first visit, user browser will save a cache copy and use them for future visits.

By using the following code in .htaccess file we can achieve our desired result,

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 30 Apr 2011 20:00:00 GMT"
</FilesMatch>

In above sample code, we have added Expires header for images and Flash files.

Put JavaScript at the Bottom:-

Using CSS code in head section is wise and logical use which is recommended by experienced coders. Web browser will be able to format it correctly.

While JavaScript should be used at the bottom of page. Because JavaScript will block parallel downloads. Which means that your web browser has to wait until the script is loaded and executed before it proceeds with loading anything that is after that JavaScript code.

Inline Vs. External:-

Everything has logic and Coding is only logic. Using JavaScript and CSS in main code is highly discouraged. JavaScript and CSS should be placed in separate file and then call it in your main code. We have three advantages,

  • Cleaner Code,
  • CSS files are highly compressible, take benefit from compression,
  • Use cache for CSS and JavaScript files for faster load.
Related posts:
  1. How to Speed Up Your Website
  2. Speed Up Your Website (Coming Soon)
  3. Thesis Customisation to Show Thumbnail in Teaser
  4. How to Disable Multi Site option in WordPress 3.0
  5. 9 Vital Tips to Secure WordPress

{ 2 comments… read them below or add one }

Amal Roy April 25, 2010 at 7:07 pm

Thanks for the tips bro, but using a cdn network speed up wordpress drastically.
.-= Amal Roy´s last blog ..Speed Up Wordpress – Ultimate Guide To Make Sites Super Fast =-.

Reply

Imran Yousaf April 25, 2010 at 10:22 pm

No doubt Roy that using CDN speeds up the loading of blog. Same is stated in above article. CDN are optimized networks to deliver the content at maximum fast speed.

Reply

Leave a Comment


× three = 9

CommentLuv badge

{ 1 trackback }

Previous post:

Next post: