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

How to Speed Up Your Website Part-II

by Imran Yousaf

  • Share
  • Sharebar
  • Share

Part-1 of article was based on server side optimisation. Now in Part-2 of same series we are focusing the wordpress for optimisation and speeding 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 feature called revision. After every 60seconds, wordpress saves copy of our non-published post which is called “Revision”. After publishing, revisions do exist in database and populates the database with useless data. Compact size of database is fastly executed. 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 page by default and uses MySQL and PHP as 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 need, and avoid own hosted Stats program. We have a variety of plugins that generate stats for us. They increase SQL queries and use PHP. Below we have code for showing the number of queries every time executed when a visitor visits your website. Only logged in user will see the query result in bottom of page.

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

Use as Few HTTP Requests as Possible:-

For successful website, Attractive graphics is key to success. No one will like dull website having text only. Modern websites use images, JavaScripts, Flash and movie clips to attract users. On each request, web server has to establish a connection, send HTTP request for several times. Hence they result in slow loading of page. 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;

 How to Speed Up Your Website Part II

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

 How to Speed Up Your Website Part II

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.
  • Full RSS Feed
    Full RSS Feed

    Subscribe to our RSS Feed with full posts for your enjoyment.

  • E-Mail Delivery
    E-Mail Delivery

    We will send full blog posts to your inbox each time new posts plublished.

{ 2 comments… read them below or add one }

Amal Roy
Twitter:
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 My ComLuv Profile

Reply

Imran Yousaf
Twitter:
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

CommentLuv Enabled

{ 2 trackbacks }

Previous post:

Next post: