How to: optimize wordpress blog for speedy loading

February 21, 2012 at 1:25 am | Posted in Wordpress | Leave a comment
Tags: , ,

When Google introduced the loading time of a website in their ranking algorithm – everyone became obsessed with minimizing the time the content on the site is properly shown to a reader.  As a WordPress user – for quite a few years now I have heard over and over again how important it was to keep the amount of plugins and widgets that load content from 3rd parties at a minimum.

Social sharing without plugins or java script

One of the plugin most frequently used across the web is the one that generates the shiny social media buttons that encourage readers to share the article on one of the dozen networks out there . Those buttons are almost always integrated on the plug with a help of a plugin or an external java script file – thus one more thing that your readers have to load each time when they access a page or an article where these buttons are placed . I wanted something more cleaner – a simple image ( there are variety of beautiful icon sets  on the web )  and a link to send the articles to the social medias.

I found some interesting tutorials on the web and after reading several here is the solution I cam out with :

For Twitter :

<a href="http://twitter.com/home?status=%20%3C?%3Cspan%20class=">php the_title(); ?&gt; ?php the_permalink(); ? @Your Twitter Handle" title="Click to send this page to Twitter!" target="_blank" rel="nofollow"&gt;<img style="border-style: none;" src="Image%20URL%20Goes%20here" alt="Send to Twitter" /></a>

For Facebook

<a href="http://www.facebook.com/share.%3Cspan%20class=">php?u=<!--?php the_permalink(); ?-->&amp;title=<!--?php the_title(); ?-->" target="_blank" rel="nofollow" &gt;<img style="border-style: none;" src="Image%20URL%20goes%20here" alt="Send to Facebook" /></a>

For the other social networks the code is quite similar – just make sure you have the correct URL for :

My Space

http://www.myspace.com/Modules/PostTo/Pages/?u=<!--?php the_permalink(); ?-->&amp;t=<!--?php the_title(); ?-->

Stumble Upon

http://www.stumbleupon.com/submit?url=<!--?php the_permalink(); ?-->&amp;title=<!--?php the_title(); ?-->

Digg

http://www.digg.com/submit?phase=2&amp;url=<!--?php the_permalink(); ?-->&amp;title=<!--?php the_title(); ?-->

If you need more examples visit this list at Pageafairs .com – b8ut remember that you have to use the WordPress custom PHP tags for the address of your article  and for the title

I have used this method to set sharing buttons on the articles on TheSkyKid.com . You would like to put these codes somewhere in the single.php file of your template which is the one that outputs your articles .

Page navigation using the build in WordPress functionality instead of a plugin

I spend quite a lot of time looking for a way to have page navigation without the need to use a plugin. I used ” Numbered Pagination Without a Plugin ” as a search term on Google and and found several web sites (1)(2) that suggested methods that involved  editing  the theme`s functions.php file – which never had any good results for me. Finally I managed to find good working solution on the Cats who code web blog . It is the following code :

<?php
global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
	'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
	'format' => '?paged=%#%',
	'current' => max( 1, get_query_var('paged') ),
	'total' => $wp_query->max_num_pages
) );
?>

 – coming straight from WordPress.org own codex . You may want to insert the code in your authors.php , archives.php and search.php and index.php files as appropriate . When I find out that method I
disabled the WP- Page Navi plugin I used until recently . I don`t have much knowledge of CSS as to make the display prettier – but if I found out how this can be achieved I will make sure to update this post.

Speed up your site with .htaccess caching

Another code that I found at Cats Who Code ( tested and proven working )

Paste the following into your.htaccess file.

# 1 YEAR
<FilesMatch ".(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"

# 1 WEEK
<filesmatch ".(jpg|jpeg|png|gif|swf)$"="">
Header set Cache-Control "max-age=604800, public"

# 2 DAYS
<filesmatch ".(xml|txt|css|js)$"="">
Header set Cache-Control "max-age=172800, proxy-revalidate"

# 1 MIN
<filesmatch ".(html|htm|php)$"="">
Header set Cache-Control "max-age=60, private, proxy-revalidate"


Do you know other techniques to speed up a Worpress?  Let me know !
Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: